diff --git a/src/lib/style-util.html b/src/lib/style-util.html index bd93a09429..84dc1377c8 100644 --- a/src/lib/style-util.html +++ b/src/lib/style-util.html @@ -106,13 +106,10 @@ var cssText = ''; // if element is a template, get content from its .content var content = element.content || element; - var sourceDoc = element.ownerDocument; var e$ = Array.prototype.slice.call( content.querySelectorAll(this.MODULE_STYLES_SELECTOR)); - for (var i=0, e, resolveDoc, addModule; i < e$.length; i++) { + for (var i=0, e; i < e$.length; i++) { e = e$[i]; - resolveDoc = sourceDoc; - addModule = null; // look inside templates for elements if (e.localName === 'template') { cssText += this._cssFromElement(e); @@ -120,25 +117,21 @@ // style elements inside dom-modules will apply to the main document // we don't want this, so we remove them here. if (e.localName === 'style') { - addModule = e.getAttribute(this.INCLUDE_ATTR); + var include = e.getAttribute(this.INCLUDE_ATTR); // get style element applied to main doc via HTMLImports polyfill e = e.__appliedElement || e; e.parentNode.removeChild(e); + cssText += this.resolveCss(e.textContent, element.ownerDocument); + // now support module refs on 'styling' elements + if (include) { + cssText += this.cssFromModules(include); + } // it's an import, assume this is a text file of css content. - } else { - // TODO(sorvell): plan is to deprecate this way to get styles; - // remember to add deprecation warning when this is done. - e = e.import && e.import.body; - resolveDoc = e.ownerDocument; + // TODO(sorvell): plan is to deprecate this way to get styles; + // remember to add deprecation warning when this is done. + } else if (e.import && e.import.body) { + cssText += this.resolveCss(e.import.body.textContent, e.import); } - // adjust paths in css. - if (e) { - cssText += this.resolveCss(e.textContent, resolveDoc); - } - } - // now support module refs on 'styling' elements - if (addModule) { - cssText += this.cssFromModules(addModule); } } return cssText; diff --git a/test/unit/styling-remote-elements.html b/test/unit/styling-remote-elements.html index 1e6f96565b..dee3c08229 100644 --- a/test/unit/styling-remote-elements.html +++ b/test/unit/styling-remote-elements.html @@ -10,6 +10,7 @@ }