Skip to content

Commit

Permalink
Merge pull request #5361 from Polymer/listen-node-type
Browse files Browse the repository at this point in the history
Expand type of LegacyElementMixin#listen and unlisten to accept EventTargets
  • Loading branch information
rictic committed Sep 19, 2018
2 parents 9dbc872 + b55c56f commit 9b322c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/legacy/legacy-element-mixin.js
Expand Up @@ -409,13 +409,13 @@ export const LegacyElementMixin = dedupingMixin((base) => {
* Convenience method to add an event listener on a given element,
* late bound to a named method on this element.
*
* @param {Element} node Element to add event listener to.
* @param {?EventTarget} node Element to add event listener to.
* @param {string} eventName Name of event to listen for.
* @param {string} methodName Name of handler method on `this` to call.
* @return {void}
*/
listen(node, eventName, methodName) {
node = /** @type {!Element} */ (node || this);
node = /** @type {!EventTarget} */ (node || this);
let hbl = this.__boundListeners ||
(this.__boundListeners = new WeakMap());
let bl = hbl.get(node);
Expand All @@ -434,14 +434,14 @@ export const LegacyElementMixin = dedupingMixin((base) => {
* Convenience method to remove an event listener from a given element,
* late bound to a named method on this element.
*
* @param {Element} node Element to remove event listener from.
* @param {?EventTarget} node Element to remove event listener from.
* @param {string} eventName Name of event to stop listening to.
* @param {string} methodName Name of handler method on `this` to not call
anymore.
* @return {void}
*/
unlisten(node, eventName, methodName) {
node = /** @type {!Element} */ (node || this);
node = /** @type {!EventTarget} */ (node || this);
let bl = this.__boundListeners && this.__boundListeners.get(node);
let key = eventName + methodName;
let handler = bl && bl[key];
Expand Down

0 comments on commit 9b322c2

Please sign in to comment.