fix(browser_adapter): work around WebKit bug with importing template elements

Closes #851

Closes #853
This commit is contained in:
Caitlin Potter 2015-03-02 16:38:39 -05:00 committed by Misko Hevery
parent 3059104e8d
commit 749a75812c
1 changed files with 11 additions and 1 deletions

View File

@ -234,7 +234,17 @@ export class BrowserDomAdapter extends DomAdapter {
return node instanceof HTMLElement && isPresent(node.shadowRoot); return node instanceof HTMLElement && isPresent(node.shadowRoot);
} }
importIntoDoc(node:Node) { importIntoDoc(node:Node) {
return document.importNode(node, true); var result = document.importNode(node, true);
// Workaround WebKit https://bugs.webkit.org/show_bug.cgi?id=137619
if (this.isTemplateElement(result) &&
!result.content.childNodes.length && node.content.childNodes.length) {
var childNodes = node.content.childNodes;
for (var i = 0; i < childNodes.length; ++i) {
result.content.appendChild(
this.importIntoDoc(childNodes[i]));
}
}
return result;
} }
isPageRule(rule) { isPageRule(rule) {
return rule.type === CSSRule.PAGE_RULE; return rule.type === CSSRule.PAGE_RULE;