From 55da0ce3e3e7a24ad235e03d9a23bce795d5e5d8 Mon Sep 17 00:00:00 2001 From: Limon Monte Date: Thu, 8 Feb 2018 16:01:44 +0200 Subject: [PATCH] Fix __addScrollListeners for polyfilled browsers --- iron-overlay-behavior.d.ts | 2 +- iron-overlay-behavior.html | 8 ++++---- .../iron-overlay-behavior-scroll-actions.html | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/iron-overlay-behavior.d.ts b/iron-overlay-behavior.d.ts index 3777ba5..bab9ebd 100644 --- a/iron-overlay-behavior.d.ts +++ b/iron-overlay-behavior.d.ts @@ -64,7 +64,7 @@ declare namespace Polymer { restoreFocusOnClose: boolean|null|undefined; /** - * Set to true to allow clicks to go through overlays. + * Set to true to allow clicks to go through overlays. * When the user clicks outside this overlay, the click may * close the overlay below. */ diff --git a/iron-overlay-behavior.html b/iron-overlay-behavior.html index 24f7a24..18e38c3 100644 --- a/iron-overlay-behavior.html +++ b/iron-overlay-behavior.html @@ -98,7 +98,7 @@ }, /** - * Set to true to allow clicks to go through overlays. + * Set to true to allow clicks to go through overlays. * When the user clicks outside this overlay, the click may * close the overlay below. */ @@ -636,7 +636,7 @@ this.__addScrollListeners(); } }, - + /** * @private */ @@ -645,7 +645,7 @@ this.__rootNodes = []; // Listen for scroll events in all shadowRoots hosting this overlay only // when in native ShadowDOM. - if ('attachShadow' in Element.prototype && 'getRootNode' in Element.prototype) { + if (Polymer.Settings.useShadow) { var node = this; while (node) { if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && node.host) { @@ -663,7 +663,7 @@ }); }, this); }, - + /** * @private */ diff --git a/test/iron-overlay-behavior-scroll-actions.html b/test/iron-overlay-behavior-scroll-actions.html index b14a7e3..84ef1c1 100644 --- a/test/iron-overlay-behavior-scroll-actions.html +++ b/test/iron-overlay-behavior-scroll-actions.html @@ -232,6 +232,12 @@ suite('scroll actions in shadow root', function() { + suiteSetup(function() { + if (!Polymer.Settings.useShadow) { + this.skip(); + } + }); + var scrollable, overlay; setup(function() { var f = fixture('scrollable'); @@ -278,7 +284,7 @@ overlay.addEventListener('iron-overlay-canceled', function(event) { assert.equal(event.detail.type, 'scroll', 'detail contains original event'); // In Polymer 1.x with dom=shadow, triggering a scroll event on a node inside a shadowRoot - // doesn't set the correct target, so we skip this check. + // doesn't set the correct target, so we skip this check. if (Polymer.Element || !Polymer.Settings.useShadow) { assert.equal(event.detail.target, scrollable, 'original scroll event target ok'); } @@ -294,6 +300,12 @@ suite('scroll actions in shadow root, overlay distributed', function() { + suiteSetup(function() { + if (!Polymer.Settings.useShadow) { + this.skip(); + } + }); + var scrollable, overlay; setup(function() { var f = fixture('scrollable'); @@ -340,7 +352,7 @@ overlay.addEventListener('iron-overlay-canceled', function(event) { assert.equal(event.detail.type, 'scroll', 'detail contains original event'); // In Polymer 1.x with dom=shadow, triggering a scroll event on a node inside a shadowRoot - // doesn't set the correct target, so we skip this check. + // doesn't set the correct target, so we skip this check. if (Polymer.Element || !Polymer.Settings.useShadow) { assert.equal(event.detail.target, scrollable, 'original scroll event target ok'); } @@ -351,10 +363,9 @@ dispatchScroll(scrollable, 0, 10); }); }); - }); - \ No newline at end of file +