From f7704384230ab11a99b18a54f26a2294e074172a Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Fri, 10 Jun 2016 16:20:23 -0700 Subject: [PATCH 1/7] Ensure custom styles updated after adding custom-style async. Fixes #3705. --- src/lib/custom-style.html | 11 +++- src/lib/render-status.html | 4 ++ test/runner.html | 4 ++ test/unit/custom-style-async-import.html | 24 +++++++++ test/unit/custom-style-async-native.html | 68 ++++++++++++++++++++++++ test/unit/custom-style-async.html | 67 +++++++++++++++++++++++ 6 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 test/unit/custom-style-async-import.html create mode 100644 test/unit/custom-style-async-native.html create mode 100644 test/unit/custom-style-async.html diff --git a/src/lib/custom-style.html b/src/lib/custom-style.html index 49d22b7cac..18e0685478 100644 --- a/src/lib/custom-style.html +++ b/src/lib/custom-style.html @@ -96,9 +96,11 @@ var styleDefaults = Polymer.StyleDefaults; var styleTransformer = Polymer.StyleTransformer; var applyShim = Polymer.ApplyShim; - + var debounce = Polymer.Debounce; var settings = Polymer.Settings; + var updateDebouncer; + Polymer({ is: 'custom-style', @@ -144,6 +146,9 @@ if (!settings.useNativeCSSProperties) { styleDefaults.addStyle(e); } + if (Polymer.RenderStatus.hasRendered()) { + updateDebouncer = debounce(updateDebouncer, this._updateStyles); + } // we may not have any textContent yet due to parser yielding // if so, wait until we do... if (e.textContent || this.include) { @@ -160,6 +165,10 @@ } }, + _updateStyles: function() { + Polymer.updateStyles(); + }, + // polyfill this style with root scoping and // apply custom properties! _apply: function(deferProperties) { diff --git a/src/lib/render-status.html b/src/lib/render-status.html index c08e7d784a..91eea5163a 100644 --- a/src/lib/render-status.html +++ b/src/lib/render-status.html @@ -57,6 +57,10 @@ this._afterNextRenderQueue.push([element, fn, args]); }, + hasRendered: function() { + return this._ready; + }, + _watchNextRender: function() { if (!this._waitingNextRender) { this._waitingNextRender = true; diff --git a/test/runner.html b/test/runner.html index 92d6c6b139..838f66a692 100644 --- a/test/runner.html +++ b/test/runner.html @@ -69,6 +69,10 @@ 'unit/custom-style.html?dom=shadow', 'unit/custom-style.html?dom=shadow&lazyRegister=true&useNativeCSSProperties=true', 'unit/custom-style-late.html', + 'unit/custom-style-async.html', + 'unit/custom-style-async.html?dom=shadow', + 'unit/custom-style-async-native.html', + 'unit/custom-style-async-native.html?dom=shadow', 'unit/dynamic-import.html', 'unit/templatizer.html', 'unit/dom-repeat.html', diff --git a/test/unit/custom-style-async-import.html b/test/unit/custom-style-async-import.html new file mode 100644 index 0000000000..f71daf492e --- /dev/null +++ b/test/unit/custom-style-async-import.html @@ -0,0 +1,24 @@ + + + + + diff --git a/test/unit/custom-style-async-native.html b/test/unit/custom-style-async-native.html new file mode 100644 index 0000000000..ea83873c02 --- /dev/null +++ b/test/unit/custom-style-async-native.html @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unit/custom-style-async.html b/test/unit/custom-style-async.html new file mode 100644 index 0000000000..47a37b1834 --- /dev/null +++ b/test/unit/custom-style-async.html @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + From e4880d9e54d0a8daa2a1e45a6660f4a25392fe62 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Fri, 10 Jun 2016 16:27:18 -0700 Subject: [PATCH 2/7] Fix lint, use query params instead of duplicate file. --- test/runner.html | 4 +- test/unit/custom-style-async-native.html | 68 ------------------------ test/unit/custom-style-async.html | 2 +- 3 files changed, 3 insertions(+), 71 deletions(-) delete mode 100644 test/unit/custom-style-async-native.html diff --git a/test/runner.html b/test/runner.html index 838f66a692..d022c2fbe1 100644 --- a/test/runner.html +++ b/test/runner.html @@ -71,8 +71,8 @@ 'unit/custom-style-late.html', 'unit/custom-style-async.html', 'unit/custom-style-async.html?dom=shadow', - 'unit/custom-style-async-native.html', - 'unit/custom-style-async-native.html?dom=shadow', + 'unit/custom-style-async.html?lazyRegister=true&useNativeCSSProperties=true', + 'unit/custom-style-async.html?lazyRegister=true&useNativeCSSProperties=true&dom=shadow', 'unit/dynamic-import.html', 'unit/templatizer.html', 'unit/dom-repeat.html', diff --git a/test/unit/custom-style-async-native.html b/test/unit/custom-style-async-native.html deleted file mode 100644 index ea83873c02..0000000000 --- a/test/unit/custom-style-async-native.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/unit/custom-style-async.html b/test/unit/custom-style-async.html index 47a37b1834..10007118cc 100644 --- a/test/unit/custom-style-async.html +++ b/test/unit/custom-style-async.html @@ -42,7 +42,7 @@