From 014a59fb1a7b67976ab4aa6f6e5ea96395aa7b57 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 9 Aug 2018 17:04:24 -0700 Subject: [PATCH 1/4] Update TemplateStamp event listen param types from Node to EventTarget. Allows passing e.g. window. --- lib/mixins/template-stamp.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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} From aff4d35690b05b364fb26b7fe97868aa4c9cbb14 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Fri, 10 Aug 2018 11:22:33 -0700 Subject: [PATCH 2/4] Also update Node->EventTarget in GestureEventListeners. --- lib/mixins/gesture-event-listeners.js | 4 ++-- 1 file changed, 2 insertions(+), 2 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} From 3da8462389b9c0f1efe5181441d1fe5fb0e77547 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Fri, 10 Aug 2018 13:36:06 -0700 Subject: [PATCH 3/4] Also update gestures.js --- lib/utils/gestures.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/utils/gestures.js b/lib/utils/gestures.js index c2a93270a1..16216f8d4f 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 Node) { // 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 From f4dd733b2978078cc48989073184692552e1babb Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Fri, 10 Aug 2018 13:47:54 -0700 Subject: [PATCH 4/4] Node->HTMLElement --- lib/utils/gestures.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/gestures.js b/lib/utils/gestures.js index 16216f8d4f..ce2342bfac 100644 --- a/lib/utils/gestures.js +++ b/lib/utils/gestures.js @@ -635,7 +635,7 @@ function _findRecognizerByEvent(evName) { * @return {void} */ export function setTouchAction(node, value) { - if (HAS_NATIVE_TA && node instanceof Node) { + 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