From ca89c643356475f21af3fd1403d50e0e139a0775 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Fri, 11 Oct 2013 16:37:48 -0700 Subject: [PATCH] Apply polyfill styling even when there's element dom, fixes https://github.com/Polymer/polymer/issues/314. Update tests. --- src/ShadowCSS.js | 45 +++++++++---------- test/html/styling/host.html | 21 ++++++--- test/html/styling/polyfill-directive.html | 2 +- test/html/styling/polyfill-rule.html | 2 +- test/html/styling/pseudo-scoping.html | 4 +- test/html/styling/pseudos.html | 4 +- test/html/styling/register.js | 53 +++++++++++++++-------- 7 files changed, 79 insertions(+), 52 deletions(-) diff --git a/src/ShadowCSS.js b/src/ShadowCSS.js index 75e6b78..1b0c43d 100644 --- a/src/ShadowCSS.js +++ b/src/ShadowCSS.js @@ -144,28 +144,29 @@ var ShadowCSS = { // 3. shim polyfill directives /* @polyfill */ // 4. shim @host and scoping shimStyling: function(root, name, extendsName) { + // use caching to make working with styles nodes easier and to facilitate + // lookup of extendee + var def = this.registerDefinition(root, name, extendsName); + // find styles and apply shimming... + if (this.strictStyling) { + this.applyScopeToContent(root, name); + } + this.shimPolyfillDirectives(def.rootStyles, name); + var cssText = this.stylesToShimmedCssText(def.scopeStyles, name); + // note: it's critical that polyfill-rules are not shimmed. + cssText += '\n\n' + this.extractPolyfillRules(def.scopeStyles, name); + // provide shimmedStyle for user extensibility + def.shimmedStyle = cssTextToStyle(cssText); if (root) { - // use caching to make working with styles nodes easier and to facilitate - // lookup of extendee - var def = this.registerDefinition(root, name, extendsName); - // find styles and apply shimming... - if (this.strictStyling) { - this.applyScopeToContent(root, name); - } - this.shimPolyfillDirectives(def.rootStyles, name); - var cssText = this.stylesToShimmedCssText(def.scopeStyles, name); - // note: it's critical that polyfill-rules are not shimmed. - cssText += '\n\n' + this.extractPolyfillRules(def.scopeStyles, name); - // provide shimmedStyle for user extensibility - root.shimmedStyle = def.shimmedStyle = cssTextToStyle(cssText); - // remove existing style elements - for (var i=0, l=def.rootStyles.length, s; (i