Is the "this" value in a DOM event handler bound to any "EventTarget" rather than only to DOM elements?
Briefly

MDN's documentation suggests that 'this' in event handlers refers specifically to the DOM element. However, this is misleading since 'this' actually refers to the EventTarget. EventTargets include not only HTML elements but also objects like `document` and `window`. For example, in `document.addEventListener`, `this` resolves to `document`, highlighting its broader application. Technical documentation should specify 'EventTarget' to avoid confusion and accurately portray the behavior of event listeners. This affirmation aligns with the standards outlined in the DOM specifications.
When a handler function is called as an event listener, the value of this is the EventTarget on which the event listener is registered.
The specification states that the this value of the function is bound to the specific event target, which can be a wider domain than just HTML elements.
It's crucial to be precise in technical documentation; using 'EventTarget' would clarify the scope and improve understanding for developers.
In practice, understanding that this points to the EventTarget is crucial for accurately explaining how JavaScript DOM event handling works.
Read at SitePoint Forums | Web Development & Design Community
[
|
]