From e8167f7f73eadb5ae11d98c0071afcb693c3ea0a Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Fri, 10 Aug 2018 21:32:22 -0700 Subject: [PATCH] Update TemplateStamp event listen param types from Node to EventTarget. (#5320) Update TemplateStamp event listen param types from Node to EventTarget. Allows passing e.g. window. --- lib/mixins/gesture-event-listeners.js | 4 ++-- lib/mixins/template-stamp.js | 6 +++--- lib/utils/gestures.js | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/mixins/gesture-event-listeners.js b/lib/mixins/gesture-event-listeners.js index 37dc78bb97..984036aaf5 100644 --- a/lib/mixins/gesture-event-listeners.js +++ b/lib/mixins/gesture-event-listeners.js @@ -45,7 +45,7 @@ export const GestureEventListeners = dedupingMixin( /** * Add the event listener to the node if it is a gestures event. * - * @param {!Node} node Node to add event listener to + * @param {!EventTarget} node Node to add event listener to * @param {string} eventName Name of event * @param {function(!Event):void} handler Listener function to add * @return {void} @@ -60,7 +60,7 @@ export const GestureEventListeners = dedupingMixin( /** * Remove the event listener to the node if it is a gestures event. * - * @param {!Node} node Node to remove event listener from + * @param {!EventTarget} node Node to remove event listener from * @param {string} eventName Name of event * @param {function(!Event):void} handler Listener function to remove * @return {void} diff --git a/lib/mixins/template-stamp.js b/lib/mixins/template-stamp.js index 26b378f2e4..3ae0607e01 100644 --- a/lib/mixins/template-stamp.js +++ b/lib/mixins/template-stamp.js @@ -444,7 +444,7 @@ export const TemplateStamp = dedupingMixin( * This method generates a handler function that looks up the method * name at handling time. * - * @param {!Node} node Node to add listener on + * @param {!EventTarget} node Node to add listener on * @param {string} eventName Name of event * @param {string} methodName Name of method * @param {*=} context Context the method will be called on (defaults @@ -462,7 +462,7 @@ export const TemplateStamp = dedupingMixin( /** * Override point for adding custom or simulated event handling. * - * @param {!Node} node Node to add event listener to + * @param {!EventTarget} node Node to add event listener to * @param {string} eventName Name of event * @param {function(!Event):void} handler Listener function to add * @return {void} @@ -475,7 +475,7 @@ export const TemplateStamp = dedupingMixin( /** * Override point for adding custom or simulated event handling. * - * @param {!Node} node Node to remove event listener from + * @param {!EventTarget} node Node to remove event listener from * @param {string} eventName Name of event * @param {function(!Event):void} handler Listener function to remove * @return {void} diff --git a/lib/utils/gestures.js b/lib/utils/gestures.js index c2a93270a1..ce2342bfac 100644 --- a/lib/utils/gestures.js +++ b/lib/utils/gestures.js @@ -493,7 +493,7 @@ function _handleTouchAction(ev) { /** * Adds an event listener to a node for the given gesture type. * - * @param {!Node} node Node to add listener on + * @param {!EventTarget} node Node to add listener on * @param {string} evType Gesture type: `down`, `up`, `track`, or `tap` * @param {!function(!Event):void} handler Event listener function to call * @return {boolean} Returns true if a gesture event listener was added. @@ -509,7 +509,7 @@ export function addListener(node, evType, handler) { /** * Removes an event listener from a node for the given gesture type. * - * @param {!Node} node Node to remove listener from + * @param {!EventTarget} node Node to remove listener from * @param {string} evType Gesture type: `down`, `up`, `track`, or `tap` * @param {!function(!Event):void} handler Event listener function previously passed to * `addListener`. @@ -527,7 +527,7 @@ export function removeListener(node, evType, handler) { * automate the event listeners for the native events * * @private - * @param {!Node} node Node on which to add the event. + * @param {!EventTarget} node Node on which to add the event. * @param {string} evType Event type to add. * @param {function(!Event)} handler Event handler function. * @return {void} @@ -566,7 +566,7 @@ function _add(node, evType, handler) { * automate event listener removal for native events * * @private - * @param {!Node} node Node on which to remove the event. + * @param {!EventTarget} node Node on which to remove the event. * @param {string} evType Event type to remove. * @param {function(!Event): void} handler Event handler function. * @return {void} @@ -630,12 +630,12 @@ function _findRecognizerByEvent(evName) { * This value is checked on first move, thus it should be called prior to * adding event listeners. * - * @param {!Node} node Node to set touch action setting on + * @param {!EventTarget} node Node to set touch action setting on * @param {string} value Touch action value * @return {void} */ export function setTouchAction(node, value) { - if (HAS_NATIVE_TA) { + if (HAS_NATIVE_TA && node instanceof HTMLElement) { // NOTE: add touchAction async so that events can be added in // custom element constructors. Otherwise we run afoul of custom // elements restriction against settings attributes (style) in the