From 2356f7b8f08ba6b2a4a19f59de5abeff7081383c Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Tue, 11 Apr 2017 11:01:39 -0700 Subject: [PATCH] Only style elements with templates dom-repeat and/or dom-if booting before custom-style is registered can break the complicated loading strategy of ShadyCSS. By only calling ShadyCSS for elements with templates, we both fix this issue and improve performance for template-less element booting Fixes #4521 --- lib/mixins/element-mixin.html | 2 +- test/runner.html | 1 + test/unit/styling-only-with-template.html | 78 +++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 test/unit/styling-only-with-template.html diff --git a/lib/mixins/element-mixin.html b/lib/mixins/element-mixin.html index 30af1ec1a7..f00316c6e8 100644 --- a/lib/mixins/element-mixin.html +++ b/lib/mixins/element-mixin.html @@ -596,7 +596,7 @@ * @override */ connectedCallback() { - if (window.ShadyCSS) { + if (window.ShadyCSS && this._template) { window.ShadyCSS.styleElement(this); } if (!this.__dataInitialized) { diff --git a/test/runner.html b/test/runner.html index 9a9f1b003a..3b35f9c9f1 100644 --- a/test/runner.html +++ b/test/runner.html @@ -36,6 +36,7 @@ 'unit/styling-cross-scope-var.html', 'unit/styling-cross-scope-apply.html', 'unit/styling-cross-scope-unknown-host.html', + 'unit/styling-only-with-template.html', 'unit/custom-style.html', 'unit/custom-style-late.html', 'unit/custom-style-async.html', diff --git a/test/unit/styling-only-with-template.html b/test/unit/styling-only-with-template.html new file mode 100644 index 0000000000..8239ad595d --- /dev/null +++ b/test/unit/styling-only-with-template.html @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + \ No newline at end of file