Events are everywhere in web programming — input change, mouse move, button click, and page scroll are all forms of events. These are the actions t...
For further actions, you may consider blocking this person and/or reporting abuse
TIL about
eventPhase
. It really doesn't matter how long you're in this profession, you really do learn something new every day.Totally agree on this one. 👍
Thank you for this! I had a bad interview a month ago where the question came up as to how to execute the parent node handler first and despite 20 years of experience I really could not remember. There just hasn’t been a scenario I’ve needed to do this and my past reading of
useCapture
in the docs was not coming to me. Today I got the answer and it was a wonderful reminder. Thank you!The only thing that could make this post better might be an example of how this might be useful. I can imagine some analytics cases but that’s not direct functionality.
Thanks for your feedback. I am sorry to hear about your interview.
Regarding the
capturing phase
, I haven't seen/found any practical use cases of it yet.But the
bubbling phase
is the core of event delegation.Interestingly, React uses this mechanism to attach all of your event handlers at the root DOM container (v17).
What is interesting here is that Phil failed his interview for not remembering something that IS NOT USEFUL, or maybe is in some very weird corner case...
Anyway, nice article Amandeep!
Thanks for your comment. 🙂👍
I am surprised that someone could test you based on if you know how event capturing works. These things are not what we do everyday and thus hard to come by, or you just forget. And that's why docs are there when you need a refresher.
I totally don't condone these interviews. I personally would stay away from these if I could.
Agreed. It's stupid to expect someone to know everything there is to know about web technologies. There is so much to know (and then more) that questioning someone without the ability to google something is pointless. A better test would be to look at how someone would solve a particular problem with all the tools at their disposal.
Exactly this. Testing how a candidate can memorise and regurgitate documentation is useless. Test how they solve problems and how they interact with you and your team. This is how you find good developers that your team can work with (which is just as, if not more, important as the candidates skillset).
Peculiar how React's synthetic event system ignores the handleEvent portion of the EventListener interface which allows objects to listen to events.
JS Fiddle
Seems Preact is looking into adding support for it (see also radEventListener: a Tale of Client-side Framework Performance).
Wow...really helpful👍
wow didn't have any idea about this. Thanks.
Love this article Clear, Complete and Consise.
Thank you. Glad that it was helpful 🙂
Very helpful post, thanks. Should the last comment in the last code block say element2?
Thanks for the feedback and that Typo 🙂👍. Cheers