View Full Version : [CLOSED] component.hasListeners contains invalid information

23 Jul 2015, 8:33 AM
Specifing controller's listen config on component domain for any selector and any event increases hasListeners property for the specified event for ALL components instead of only specified. This makes hasListeners property useless.

Also this produces an ARIA console error on menu button, see example.

Example: https://fiddle.sencha.com/#fiddle/r00

23 Jul 2015, 12:51 PM
Not really sure why you're saying this is a bug. The listener for the controller gets wired in at a very early stage and needs to dynamically handle components as they come online/offline. As such, we only determine whether or not something matches the selector when an event is fired, there's too much overhead in trying to manage the component lifecycle to attach/detach listeners in such a way. So, technically speaking, all buttons do have a click listener, but we don't know whether or not it matches until fire time.

If you want to check if a specific instance has a listener, you could use:


As far as the ARIA error goes, if you're looking to create an ARIA compliant app, you shouldn't use the menu button. If not, then you can ignore it.

24 Jul 2015, 1:32 AM
I reported this as a bug because of ARIA warning about the event handler which I haven't directly attached to the component. Now I undestand how it works, thanks. So, if using a menu button makes an application non ARIA compliant why don't ExtJs warns me about a handler but not about a whole menubutton?

And one interesting question to think about: as I see, using component domain in controller listen config is a very typical scenario, so what the real use of hasListeners then? You can't relly on hasListeners.click because it always true in typical scenario and you can't relly on hasListeners.hasOwnProperty('click') because you can miss that listener in controller which supplied with exactly matching selector for the component? May be hasListeners should be deprecated?