diff options
| author | Misko Hevery | 2010-04-26 11:57:33 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-04-26 11:57:33 -0700 |
| commit | 02fa10f93ce5a75dd925f13ec7456802a6e120e4 (patch) | |
| tree | a7a90bbdd96a52c4183adbdc69ed92ea6dd95a1b /src/Compiler.js | |
| parent | 076f37a5ec26e88c5aeb2f37aa19ea7b2516d9f3 (diff) | |
| download | angular.js-02fa10f93ce5a75dd925f13ec7456802a6e120e4.tar.bz2 | |
allow the widget to change structure of the DOM and have the compiler follow the replaced element.
Diffstat (limited to 'src/Compiler.js')
| -rw-r--r-- | src/Compiler.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Compiler.js b/src/Compiler.js index 21302054..290eb3b7 100644 --- a/src/Compiler.js +++ b/src/Compiler.js @@ -77,7 +77,7 @@ function Compiler(textMarkup, attrMarkup, directives, widgets){ Compiler.prototype = { compile: function(rawElement) { rawElement = jqLite(rawElement); - var template = this.templatize(rawElement) || new Template(); + var template = this.templatize(rawElement, 0, 0) || new Template(); return function(element, parentScope){ element = jqLite(element); var scope = parentScope && parentScope.$eval ? @@ -95,7 +95,7 @@ Compiler.prototype = { }; }, - templatize: function(element, priority){ + templatize: function(element, elementIndex, priority){ var self = this, widget, directiveFns = self.directives, @@ -130,7 +130,11 @@ Compiler.prototype = { if (widget) { descend = false; directives = false; + var parent = element.parent(); template.addInit(widget.call(selfApi, element)); + if (parent) { + element = jqLite(parent[0].childNodes[elementIndex]); + } } if (descend){ // process markup for text nodes only @@ -156,7 +160,7 @@ Compiler.prototype = { // Process non text child nodes if (descend) { eachNode(element, function(child, i){ - template.addChild(i, self.templatize(child, priority)); + template.addChild(i, self.templatize(child, i, priority)); }); } return template.empty() ? null : template; |
