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