From ea0abb9585b7b3196268f92775bc3810b1efd314 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Fri, 15 Dec 2017 11:21:03 -0800 Subject: [PATCH] Templatize: remove slots when hiding children Fixes #4977. When templatized content is hidden (via `_showHideChildren`) as in `dom-if` top level `` elements are now removed instead of being hidden. This ensures that assigned nodes are not displayed in false-y dom-if elements. --- lib/utils/templatize.html | 12 +++ test/unit/dom-if-elements.html | 22 +++++ test/unit/dom-if.html | 174 ++++++++++++++++++++------------- 3 files changed, 139 insertions(+), 69 deletions(-) diff --git a/lib/utils/templatize.html b/lib/utils/templatize.html index c4290724e2..96e63cdc77 100644 --- a/lib/utils/templatize.html +++ b/lib/utils/templatize.html @@ -165,6 +165,18 @@ } else { n.textContent = n.__polymerTextContent__; } + // remove and replace slot + } else if (n.localName === 'slot') { + if (hide) { + n.__polymerParent__ = n.parentNode; + n.__polymerSibling__ = n.nextSibling; + n.parentNode.removeChild(n); + } else { + const parent = n.__polymerParent__; + if (parent) { + parent.insertBefore(n, n.__polymerSibling__ || null); + } + } } else if (n.style) { if (hide) { n.__polymerDisplay__ = n.style.display; diff --git a/test/unit/dom-if-elements.html b/test/unit/dom-if-elements.html index f6d39dac84..ea877ef653 100644 --- a/test/unit/dom-if-elements.html +++ b/test/unit/dom-if-elements.html @@ -190,6 +190,28 @@ + + + + +