From c90abf057b0370cf5beb62aa960f1df008c802ef Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sun, 13 Feb 2011 16:13:21 -0800 Subject: Changed the angular.compile(element)(scope[, cloneAttachNode]) --- src/Compiler.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/Compiler.js') diff --git a/src/Compiler.js b/src/Compiler.js index 77c83846..78d7a2b0 100644 --- a/src/Compiler.js +++ b/src/Compiler.js @@ -93,14 +93,17 @@ Compiler.prototype = { } } template = this.templatize(templateElement, index, 0) || new Template(); - return function(scope, element){ - scope = scope || createScope(); - element = element === true - ? templateElement.cloneNode() - : (element ? jqLite(element) : templateElement); + return function(scope, cloneConnectFn){ + // important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart + // and sometimes changes the structure of the DOM. + var element = cloneConnectFn + ? JQLitePrototype.clone.call(templateElement) // IMPORTAN!!! + : templateElement; + scope = scope || createScope(); element.data($$scope, scope); - template.attach(element, scope); scope.$element = element; + (cloneConnectFn||noop)(element, scope); + template.attach(element, scope); scope.$eval(); return {scope:scope, view:element}; }; -- cgit v1.2.3