From 26112859d2ae6916f2066acafbf6c30f0fede797 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Thu, 23 Jul 2015 19:40:44 -0700 Subject: [PATCH] Cache style.display & textContent and re-apply on true. Fixes #2037 --- src/lib/template/dom-if.html | 21 ++++---------------- src/lib/template/templatizer.html | 18 ++++++++++++++--- test/smoke/dom-if.html | 12 +++++++---- test/unit/dom-if-elements.html | 4 ++-- test/unit/dom-if.html | 33 +++++++++++++------------------ 5 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/lib/template/dom-if.html b/src/lib/template/dom-if.html index bd3f5c125c..7c5e049177 100644 --- a/src/lib/template/dom-if.html +++ b/src/lib/template/dom-if.html @@ -85,10 +85,10 @@ }, /** - * Forces the element to render its content. Normally rendering is - * asynchronous to a provoking change. This is done for efficiency so - * that multiple changes trigger only a single render. The render method - * should be called if, for example, template rendering is required to + * Forces the element to render its content. Normally rendering is + * asynchronous to a provoking change. This is done for efficiency so + * that multiple changes trigger only a single render. The render method + * should be called if, for example, template rendering is required to * validate application state. */ render: function() { @@ -98,7 +98,6 @@ _render: function() { if (this.if) { if (!this.ctor) { - this._wrapTextNodes(this._content || this.content); this.templatize(this); } this._ensureInstance(); @@ -140,18 +139,6 @@ } }, - _wrapTextNodes: function(root) { - // wrap text nodes in span so they can be hidden. - for (var n = root.firstChild; n; n=n.nextSibling) { - if (n.nodeType === Node.TEXT_NODE && n.textContent.trim()) { - var s = document.createElement('span'); - root.insertBefore(s, n); - s.appendChild(n); - n = s; - } - } - }, - _showHideChildren: function() { var hidden = this.__hideTemplateChildren__ || !this.if; if (this._instance) { diff --git a/src/lib/template/templatizer.html b/src/lib/template/templatizer.html index 299b6c5e4e..e89efef190 100644 --- a/src/lib/template/templatizer.html +++ b/src/lib/template/templatizer.html @@ -144,10 +144,22 @@ var c = this._children; for (var i=0; i

Lazy / hidden

-
-
I have been
+ Text node +
+
I have been
+ Text node diff --git a/test/unit/dom-if-elements.html b/test/unit/dom-if-elements.html index d1e6ebe518..f569bebfa3 100644 --- a/test/unit/dom-if-elements.html +++ b/test/unit/dom-if-elements.html @@ -159,7 +159,7 @@ }); - +