From 717fc3afba3f58a05b77569599289fd599188938 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Wed, 18 May 2016 15:00:17 -0700 Subject: [PATCH] Fixes #3661: ensure that cached style points to the applied style for Shady DOM styling. This ensures that the cache can be used to determine if a style needs to be applied to the document and prevents extra unnecessary styles from being added. This could happen when a property cascaded to a nested element and updateStyles was called after properties have changed. --- src/standard/x-styling.html | 9 ++++ test/unit/styling-cross-scope-var.html | 64 ++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/src/standard/x-styling.html b/src/standard/x-styling.html index 23150ed4f8..211565ec09 100644 --- a/src/standard/x-styling.html +++ b/src/standard/x-styling.html @@ -187,6 +187,15 @@ this._styleProperties, this._scopeSelector, info && info.style); // apply scope selector if (!nativeShadow) { + // update cached style to point to new style. + // TODO(sorvell): under ShadyDOM, the cached style is + // used to style the element and the cache must be updated to point + // to the 'active' style so elements can determine if updates are needed. + // This is not the case under Shadow DOM. Ideally the cache + // would be decoupled from style application/use. + if (info) { + info.style = style; + } propertyUtils.applyElementScopeSelector(this, this._scopeSelector, oldScopeSelector, this._scopeCssViaAttr); } diff --git a/test/unit/styling-cross-scope-var.html b/test/unit/styling-cross-scope-var.html index 36d0063b0d..2463842343 100644 --- a/test/unit/styling-cross-scope-var.html +++ b/test/unit/styling-cross-scope-var.html @@ -67,6 +67,10 @@ padding: 8px; border: var(--scope-var); } + + :host(.foo) { + border: var(--scope-var-foo); + } Host property @@ -77,6 +81,34 @@ + + + + + + + + + +