Skip to content

Commit

Permalink
just move the style instead
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Sep 21, 2017
1 parent 155ab8a commit 61b2c8a
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/elements/custom-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,13 @@
https://crbug.com/523952
If this element is not in the main document, then it must be in an HTML Import document.
In that case, copy the style into the main document and disable the current style.
`__appliedElement` is used by the HTML Imports polyfill for this use case, and already understood by
ShadyCSS's Custom Style Interface.
In that case, move the custom style to the main document.
The ordering of `<custom-style>` should stay the same as when loaded by HTML Imports, but there may be odd
cases of ordering w.r.t the main document styles.
*/
if (this.ownerDocument !== window.document) {
let appliedStyle = style.cloneNode(true);
style.__appliedElement = appliedStyle;
// disable style in the HTML Import document
style.setAttribute('media', 'none');
window.document.head.appendChild(appliedStyle);
window.document.head.appendChild(this);
}
return this._style;
}
Expand Down

0 comments on commit 61b2c8a

Please sign in to comment.