Merge pull request #4850 from Polymer/1.x-html-imports-styling-workaround

Copy <style is="custom-style"> to the main document
This commit is contained in:
Daniel Freedman
2017-09-21 14:28:58 -07:00
committed by GitHub
+13
View File
@@ -123,6 +123,19 @@ Note, all features of `custom-style` are available when defining styles as part
if (this.__appliedElement !== this) {
this.__appliedElement.__cssBuild = this.__cssBuild;
}
/*
HTML Imports styling the main document are deprecated in Chrome
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, 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 && this.__appliedElement === this) {
document.head.appendChild(this);
}
// needed becuase elements in imports do not get 'attached'
// TODO(sorvell): we could only do this if and only if
// this.ownerDocument != document;