From b1fc3e87c6606c8335655a3dc395cefa51a42b24 Mon Sep 17 00:00:00 2001 From: Rado Kirov Date: Thu, 19 Feb 2015 16:18:46 -0800 Subject: [PATCH] fix(view): move nodes into the live document when cloning. Closes #724 --- modules/angular2/src/core/compiler/view.js | 2 +- modules/angular2/src/facade/dom.dart | 3 +++ modules/angular2/src/facade/dom.es6 | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/core/compiler/view.js b/modules/angular2/src/core/compiler/view.js index 10d683ea07..b190c36254 100644 --- a/modules/angular2/src/core/compiler/view.js +++ b/modules/angular2/src/core/compiler/view.js @@ -308,7 +308,7 @@ export class ProtoView { } _instantiate(hostElementInjector: ElementInjector, eventManager: EventManager): View { - var rootElementClone = this.instantiateInPlace ? this.element : DOM.clone(this.element); + var rootElementClone = this.instantiateInPlace ? this.element : DOM.importIntoDoc(this.element); var elementsWithBindingsDynamic; if (this.isTemplateElement) { elementsWithBindingsDynamic = DOM.querySelectorAll(DOM.content(rootElementClone), NG_BINDING_CLASS_SELECTOR); diff --git a/modules/angular2/src/facade/dom.dart b/modules/angular2/src/facade/dom.dart index 79d0ec859c..25283272a1 100644 --- a/modules/angular2/src/facade/dom.dart +++ b/modules/angular2/src/facade/dom.dart @@ -187,6 +187,9 @@ class DOM { node.nodeType == Node.TEXT_NODE; static bool isElementNode(Node node) => node.nodeType == Node.ELEMENT_NODE; + static Node importIntoDoc(Node node) { + return document.importNode(node, true); + } } class CSSRuleWrapper { diff --git a/modules/angular2/src/facade/dom.es6 b/modules/angular2/src/facade/dom.es6 index f2175e218f..beebeffefa 100644 --- a/modules/angular2/src/facade/dom.es6 +++ b/modules/angular2/src/facade/dom.es6 @@ -219,6 +219,9 @@ export class DOM { static isElementNode(node:Node):boolean { return node.nodeType === Node.ELEMENT_NODE; } + static importIntoDoc(node:Node) { + return document.importNode(node, true); + } } export class CSSRuleWrapper {