From 749a75812cfb8825d9d523b930f9e73303d1cc22 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Mon, 2 Mar 2015 16:38:39 -0500 Subject: [PATCH] fix(browser_adapter): work around WebKit bug with importing template elements Closes #851 Closes #853 --- modules/angular2/src/dom/browser_adapter.es6 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/dom/browser_adapter.es6 b/modules/angular2/src/dom/browser_adapter.es6 index df90785ec0..81cf7d9790 100644 --- a/modules/angular2/src/dom/browser_adapter.es6 +++ b/modules/angular2/src/dom/browser_adapter.es6 @@ -234,7 +234,17 @@ export class BrowserDomAdapter extends DomAdapter { return node instanceof HTMLElement && isPresent(node.shadowRoot); } 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) { return rule.type === CSSRule.PAGE_RULE;