Skip to content

Commit

Permalink
Fixes #2304: avoid trying to read style data from imports that did no…
Browse files Browse the repository at this point in the history
…t load.
  • Loading branch information
Steven Orvell committed Aug 18, 2015
1 parent a42ca09 commit 0d1f206
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/lib/style-util.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,39 +106,32 @@
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);
} else {
// 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;
Expand Down
1 change: 1 addition & 0 deletions test/unit/styling-remote-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
</style>
<template>
<link rel="import" type="css" href="styling-remote-sheet.css">
<div id="me" class="border">border should be 10px</div>
</template>
<script>
Expand Down

0 comments on commit 0d1f206

Please sign in to comment.