Re: [whatwg/dom] [Proposal] Add EventTarget.getEventListeners() (#412)

@LeaVerou like I've said, I love the *stealth* (or *closed*) idea, but I respectfully disagree on this part:

> most event listeners exist to enable functionality and don't care one iota about encapsulation

and the reason is the opposite of:

> most use cases for getEventListeners() are about doing stuff with listeners you did not attach yourself

with NodeJS you "own" the server that runs the code (or the lambda, or whatever) and you k now for sure what script gets in and what not ... you don't have this open world where everyone can do whatever they wont because *YOLO* or because evil scripts (ads industry is full of these) you cannot control, because you ship one bit of a front end you might never control, as library author, while code used in a server has a different story/use-case for all listeners.

That being said, none of my libraries welcome a method that exposes internal listeners, mostly because I use extensively [the event listener interface with hadnleEvent](https://dom.spec.whatwg.org/#interface-eventtarget) which is about attaching a whole state handler to an element, not just a callback, and that's [proven to be extremely effective](https://webreflection.medium.com/dom-handleevent-a-cross-platform-standard-since-year-2000-5bf17287fd38) and handy.

lit-element, to name others, use this pattern too ... and so do tons of other frameworks. I never want my attached states/behaviors to ever leak to undesired scripts I don't authorized, so I hope instead of telling me I am sidetracking the issue somebody would understand what is the issue I am talking about.

Yet, if this changes, which is a breaking expectations change to me, I need to add that third option everywhere, and say goodbye to legacy compatibility because once you add an object, old browsers take that as a `truthy` value and set the handler as capturing instead. This is a minor gotcha in 2022, yet something else some of my code needs to take care about (or polyfills around this requested braking change).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/412#issuecomment-1063119562
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/412/1063119562@github.com>

Received on Wednesday, 9 March 2022 16:36:43 UTC