From 5967f2dda33a17fb6ea49d3b1ad90612052b5e4e Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Wed, 27 Jul 2016 11:17:05 -0700 Subject: [PATCH] Fixes #3801. Ensure style host calculates custom properties before element. This ensures the scope's styles are prepared to be inspected by the element for matching rules. --- src/standard/x-styling.html | 7 ++- test/runner.html | 1 + test/unit/custom-style-scope-cache.html | 82 +++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 test/unit/custom-style-scope-cache.html diff --git a/src/standard/x-styling.html b/src/standard/x-styling.html index f658592380..2aaf734d41 100644 --- a/src/standard/x-styling.html +++ b/src/standard/x-styling.html @@ -118,6 +118,10 @@ _updateStyleProperties: function() { var info, scope = this._findStyleHost(); + // ensure scope properties exist before any access of scope cache. + if (!scope._styleProperties) { + scope._computeStyleProperties(); + } // install cache in host if it doesn't exist. if (!scope._styleCache) { scope._styleCache = new Polymer.StyleCache(); @@ -184,8 +188,7 @@ _computeStyleProperties: function(scopeProps) { // get scope and make sure it has properties var scope = this._findStyleHost(); - // force scope to compute properties if they don't exist or if forcing - // and it doesn't need properties + // force scope to compute properties if they don't exist if (!scope._styleProperties) { scope._computeStyleProperties(); } diff --git a/test/runner.html b/test/runner.html index b51d438969..4121d994e6 100644 --- a/test/runner.html +++ b/test/runner.html @@ -69,6 +69,7 @@ 'unit/styling-cross-scope-unknown-host.html', 'unit/style-cache.html', 'unit/custom-style.html', + 'unit/custom-style-scope-cache.html', 'unit/custom-style.html?lazyRegister=true&useNativeCSSProperties=true', 'unit/custom-style.html?dom=shadow', 'unit/custom-style.html?dom=shadow&lazyRegister=true&useNativeCSSProperties=true', diff --git a/test/unit/custom-style-scope-cache.html b/test/unit/custom-style-scope-cache.html new file mode 100644 index 0000000000..ecd3ef98b5 --- /dev/null +++ b/test/unit/custom-style-scope-cache.html @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + +