Clicking an icon does nothing
A list uses one parent click listener. Its handler checks whether event.target matches button[data-row-id]. Clicking button text works, but clicking the SVG icon inside the same button does not. Explain the bug and propose a fix that also works when new rows are appended.
Model Answer & Explanation
event.target may be a descendant like the SVG, while event.currentTarget is the parent with the delegated listener. For an Element target, use closest('button[data-row-id]'), then check that the matched button belongs to the intended parent. The same parent listener handles new rows through bubbling.
What a Strong Answer Covers
- Distinguish the original event target from the listener’s element.
- Find the nearest matching button and check its boundary.