How Does Addeventlistener Work Under The Hood?
Solution 1:
After execution of the above code elem is an instance of
HTMLDivElement
interface. My big question is what exactlyaddEventListener()
method does.In which DOM objects does it register the listener
On the DOM element on which addEventListener
was called. (Of course, events on sub-elements could bubble up).
and how it does that (which properties of these DOM objects it changes)
How it does that is an internal implementation detail. It changes no user-visible properties of the DOM object.
In other words, I'd like to know how elem is informed about the addition of a listener
It is not.
which of its properties (all of them down to its prototype chain) are affected
None of them.
For example I know that Event.prototype has crucial properties like type, target; however I cannot "connect" them with elem...
Those are properties on Event
, which has nothing to do with elem
.
Post a Comment for "How Does Addeventlistener Work Under The Hood?"