diff options
| author | Misko Hevery | 2012-03-15 22:18:06 -0700 |
|---|---|---|
| committer | Misko Hevery | 2012-03-19 11:35:10 -0700 |
| commit | 9918b748be01266eb10db39d51b4d3098d54ab66 (patch) | |
| tree | 41b9b46a1ac03bff7ec7e5d8027dd255e0c55ecc /src/service/compiler.js | |
| parent | 6ecac8e71a84792a434d21db2c245b3648c55f18 (diff) | |
| download | angular.js-9918b748be01266eb10db39d51b4d3098d54ab66.tar.bz2 | |
fix(compiler): allow transclusion of root elements
Fixed an issue where a directive that uses transclusion (such as ngRepeat) failed to link if it was declared on the root element of the compilation tree. (For example ngView or ngInclude including template where ngRepeat was the top most element).
Diffstat (limited to 'src/service/compiler.js')
| -rw-r--r-- | src/service/compiler.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/service/compiler.js b/src/service/compiler.js index 8aba28e4..6cbfc9d3 100644 --- a/src/service/compiler.js +++ b/src/service/compiler.js @@ -225,7 +225,10 @@ function $CompileProvider($provide) { //================================ function compile(templateElement, transcludeFn, maxPriority) { - templateElement = jqLite(templateElement); + if (!(templateElement instanceof jqLite)) { + // jquery always rewraps, where as we need to preserve the original selector so that we can modify it. + templateElement = jqLite(templateElement); + } // We can not compile top level text elements since text nodes can be merged and we will // not be able to attach scope data to them, so we will wrap them in <span> forEach(templateElement, function(node, index){ @@ -488,7 +491,7 @@ function $CompileProvider($provide) { template = jqLite(templateNode); templateNode = (element = templateAttrs.$element = jqLite( '<!-- ' + directiveName + ': ' + templateAttrs[directiveName] + ' -->'))[0]; - template.replaceWith(templateNode); + replaceWith(rootElement, jqLite(template[0]), templateNode); childTranscludeFn = compile(template, transcludeFn, terminalPriority); } else { template = jqLite(JQLiteClone(templateNode)); |
