Loading homepage
Attach one listener to a container and route bubbling events to matching descendants, including descendants added later.
Input: const stop = delegate(container, "click", ".action", function(event, button) { console.log(button.textContent); }); // Later: stop(); Output: Only the closest matching descendant handles each click.
Input: container.appendChild(Object.assign(document.createElement("button"), { className: "action" })); Output: New matching buttons are handled without registering new listeners.
Implement the exported function in index.js or index.ts. Tests provide fixtures for the required behavior.