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

The data returned by an API like this is going to be tough to interpret. For example, `addEventListener()` can take either a callback function *or* an object that has a `handleEvent()` method.  Also, the same listener can be used in different combination of event types and options including `capture` and `passive` so it might appear several times in the list.

If the goal is to determine whether an element has a listener for a particular event/options combo, the caller (or perhaps the API) would also need to look for listeners on ancestor elements to ensure that the event wasn't handled up the tree. It's possible many listeners won't ever be reached if an earlier listener consistently calls `stopPropagation()` but there's no way to know that from the static list.

As a further confounding variable, it seems like every major web site has click handlers attached at the `document` or `window` level that are used for analytics or ads. I just randomly went to cnn.com in Chrome and selected an element, you can see the results below. 

However, I wonder...since Chrome DevTools has access to this info, can a Chrome plugin get it as well? Would exposing for plugins be a better course of action or at least a first step proof of concept to show that exposing this level of detail in a web platform API is useful in practice?

![capture](https://user-images.githubusercontent.com/157858/33590091-11aecb84-d94b-11e7-9560-dec4e205ea6f.PNG)



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

Received on Tuesday, 5 December 2017 04:48:16 UTC