“ask” is obviously a handler in my controller and the i-tag is expanded into a fontawesome icon. If I click on the icon, my handler is called as I would expect. But the target of the event is not the div. It is some generated SVG of the icon.
I’m a bit confused, because I don’t connect any click events to the SVG. I would expect that the div is the target of the event. I found another answer which proposes to use currentTarget instead of target, but that one is null. When looking at the event via dev tools, I only see SVG elements, but not my div.
Am I missing something? I need to access data-item-url in my handler and I don’t see how to do that with the wrong event target.
It’s unclear why the event.currentTarget would be null. Including your ask() function may help us diagnose here.
Mozilla’s docs go more in depth on events and bubbling:
Thanks for your answers, which are perfectly correct. I was using target which is wrong. While debugging, I checked currentTarget in the Firefox console. There it is displayed as null, but it isn’t. I stumbled upon this in a blog post and it seems to be a general “display issue” in the Firefox console (in some situations?). Now I’m using currentTarget and everything works as expected. Thanks for your help!