- From: Benjamin Gruenbaum <notifications@github.com>
 - Date: Fri, 01 Apr 2022 05:35:12 -0700
 - To: whatwg/dom <dom@noreply.github.com>
 - Cc: Subscribed <subscribed@noreply.github.com>
 
Received on Friday, 1 April 2022 12:35:24 UTC
Just another point I thought about: Even with `getEventListeners()` it is still possible for code interested in doing so to hide event handlers and prevent removing them from consumers by overriding `EventTarget.prototype.getEventListeners()` itself before any external code can get a reference.
```js
const origGetEventListeners = EventTarget.prototype.getEventListeners;
Object.defineProperty(EventTarget.prototype, 'getEventListeners', {
  value: function myGetEventListeners(eventType) {
    return origGetEventListeners.apply(this, arguments).filter(handler => myCustomFilterLogic(handler));
  }
});
```
So encapsulation is still possible just not the default with Lea's proposal.
-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/412#issuecomment-1085844228
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/dom/issues/412/1085844228@github.com>
Received on Friday, 1 April 2022 12:35:24 UTC