Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only one real listener per listen call #2535

Merged
merged 4 commits into from
Oct 8, 2015

Conversation

dfreedm
Copy link
Member

@dfreedm dfreedm commented Oct 6, 2015

Actually use event listener cache correctly

Fixes #2534 Polymer Gestures creates a new bound handler for every listen call

Actually use event listener cache correctly

Fixes #2534 Polymer Gestures creates a new bound handler for every `listen` call
@samccone
Copy link
Contributor

samccone commented Oct 6, 2015

Is there a test we can put in place for this?

@dfreedm
Copy link
Member Author

dfreedm commented Oct 6, 2015

@samccone yep

@cdata
Copy link
Contributor

cdata commented Oct 6, 2015

A good test might be..

  1. Add a listener twice
  2. Verify that the event is only handled once
  3. Remove the listener (once)
  4. Verify that the event is no longer handled

this._listen(node, eventName,
this._createEventHandler(node, eventName, methodName));
var handler = this._recallEventHandler(this, eventName, node, methodName);
// reuse cache'd handler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍻

@cdata
Copy link
Contributor

cdata commented Oct 6, 2015

Relevant for PolymerElements/iron-selector#64

@dfreedm
Copy link
Member Author

dfreedm commented Oct 6, 2015

@sorvell or @kevinpschaaf PTAL

@@ -141,6 +141,41 @@
assert.deepEqual(el._removed[3], {target: 'div', event: 'bar'});
});
});

suite('Event Listener Cache', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woot

Gestures have counter code that should not be re-added with multiple identical
`listen` calls
@sorvell
Copy link
Contributor

sorvell commented Oct 8, 2015

LGTM

sorvell pushed a commit that referenced this pull request Oct 8, 2015
Only one real listener per `listen` call
@sorvell sorvell merged commit 9a3b78d into master Oct 8, 2015
@sorvell sorvell deleted the fix-listen-multiple-invocations branch October 8, 2015 20:06
cdata pushed a commit to PolymerElements/iron-selector that referenced this pull request Oct 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants