New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 681409 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

getEventListeners returns wrong number of listeners?

Reported by ovkadu...@gmail.com, Jan 15 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2982.0 Safari/537.36

Steps to reproduce the problem:
Please check out jsfiddle in here https://jsfiddle.net/ovkadurin/sheoje83/6/
as well as animated gif attached. 

The thing is that getEventListeners shows that there's only one listener when the same listener is bound multiple times. And that is really confusing. 
Also if selecting the element in the Elements panel and look at the Event Listeners tab on the right, then we can see that there are actually two the same listeners, which is correct.

What is the expected behavior?
getEventListeners should show correct number of listeners.

What went wrong?
Bug.

Did this work before? N/A 

Chrome version: 57.0.2982.0  Channel: canary
OS Version: 10.0
Flash Version: Shockwave Flash 24.0 r0
 
getEventListeners.gif
749 KB View Download

Comment 1 by woxxom@gmail.com, Jan 15 2017

The observed behavior is correct because:

1. there is actually just one DOM listener used inside jQuery internally as you can see by expanding the output of getEventListeners. This single jQuery listener routes the events to the bound elements.

2. the Elements panel Event Listeners tab shows two *elements*, not two *listeners*

Comment 2 by woxxom@gmail.com, Jan 15 2017

On the other hand, there is an obvious discrepancy: getEventListeners output is based on the actual DOM listener function reference, but Elements panel Event Listeners tab evidently recognizes jQuery framework and reports both calls as separate listeners (and from the underlying real DOM point of view this is incorrect because the listener function reference is the same).

Comment 3 by ajha@chromium.org, Jan 16 2017

Labels: Needs-Bisect Needs-Triage-M57

Comment 4 by ovkadu...@gmail.com, Jan 16 2017

wox...@gmail.com, thanks for information!

>>>1. there is actually just one DOM listener used inside jQuery internally as you can see by expanding the output of getEventListeners. This single jQuery listener routes the events to the bound elements.

Agree. I thought that jQuery just bind the listener directly to the element.

>>>2. the Elements panel Event Listeners tab shows two *elements*, not two *listeners*

Well. I talked about listeners which are on the right (where there are file names and line numbers).

>>> Event Listeners tab evidently recognizes jQuery framework and reports both calls as separate listeners

Having the information that the same listener (the one bound by jQuery) will be called multiple times really helps. 
-----------

Ok. So now I understand that getEventListeners returns the only listeners which are bound directly to the DOM. And there is very helpful option "Framework listeners" in the "Event Listeners" tab, that can show listeners bound by jQuery.
So, the "Framework listeners" option (which I haven't known about) does what I need.

Comment 5 by woxxom@gmail.com, Jan 16 2017

Actually, it'd reasonable to make getEventListeners return an additional property with framework listeners: this would solve the raised issue and make the function much more useful.

Comment 6 by ovkadu...@gmail.com, Jan 16 2017

wox...@gmail.com, good point!

Comment 7 by hdodda@chromium.org, Jan 17 2017

Cc: hdodda@chromium.org
Labels: -Needs-Bisect Needs-Feedback
From the discussion in above comment#4 , this seems more like a feature request or extended functioanlity request .

@woxxom/ovkadurin-- Could any one of you confirm this , so that we can triage this.

Note : Removing Bisect-label, please add if required.
Thanks!

Comment 8 by ovkadu...@gmail.com, Jan 17 2017

hdodda@chromium.org, Ok with me.
Status: Untriaged (was: Unconfirmed)
Considering this as a feature request and marking it as Untriaged to get it addressed.

Thanks..

Comment 10 by caseq@chromium.org, Jan 17 2017

Labels: -Needs-Feedback
Owner: kozyatinskiy@chromium.org
Status: Assigned (was: Untriaged)

Comment 11 by caseq@chromium.org, Jan 17 2017

Cc: caseq@chromium.org
Labels: -Needs-Triage-M57 M-58
Removing Needs-Triage-M57 label based on the above comments #2,4 & 5 and added appropriate milestone for it.
Owner: kozy@chromium.org

Sign in to add a comment