W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2012

[whatwg] Detecting eventListeners

From: Xavier Ho <contact@xavierho.com>
Date: Fri, 25 May 2012 11:34:31 +1000
Message-ID: <CALWePYxocw1hWxduaMUq3suhnLzYad91UO2M3iUrmfxSunAhtw@mail.gmail.com>
To: whatwg@whatwg.org

We're working on a project that requires detection of registered event
listeners.  Our targets are old-style "onclick" attribute bindings, events
registered via "addEventListener" (and the IE equivalent), and other custom
event libraries such as jQuery's.

As far as we can tell, there is no way to determine if an element has an
eventListener attached to it, created via "addEventListener".  There is a
sure way to remove an event (via "removeEventListener"), but we want to
enter some code path if and only if an element has an event registered,
without altering its eventListener.  This is currently not possible.

Many discussions about this topic has been raised in the past.  This
Stackoverflow answer has a good summary:

As far as the author could tell, this feature was never implemented due to
a lack of a use-case.  We have a use-case.  Could someone share some
thoughts on this?

We are also happy to hear workarounds, if anyone has previously encountered
this issue and found a way.

Received on Friday, 25 May 2012 01:35:24 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:42 UTC