Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b28f969

Browse files
committed
fix($compile): support multi-element group over text nodes
1 parent 6b12432 commit b28f969

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/ng/compile.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,10 @@ function $CompileProvider($provide) {
591591
if (!node) {
592592
throw ngError(51, "Unterminated attribute, found '{0}' but no matching '{1}' found.", attrStart, attrEnd);
593593
}
594-
if (node.hasAttribute(attrStart)) depth++;
595-
if (node.hasAttribute(attrEnd)) depth--;
594+
if (node.nodeType == 1 /** Element **/) {
595+
if (node.hasAttribute(attrStart)) depth++;
596+
if (node.hasAttribute(attrEnd)) depth--;
597+
}
596598
nodes.push(node);
597599
node = node.nextSibling;
598600
} while (depth > 0);

test/ng/compileSpec.js

+13
Original file line numberDiff line numberDiff line change
@@ -2747,6 +2747,19 @@ describe('$compile', function() {
27472747
}));
27482748

27492749

2750+
it('should support grouping over text nodes', inject(function($compile, $rootScope) {
2751+
$rootScope.show = false;
2752+
element = $compile(
2753+
'<div>' +
2754+
'<span ng-repeat-start="i in [1,2]">{{i}}A</span>' +
2755+
':' + // Important: proves that we can iterate over non-elements
2756+
'<span ng-repeat-end>{{i}}B;</span>' +
2757+
'</div>')($rootScope);
2758+
$rootScope.$digest();
2759+
expect(element.text()).toEqual('1A:1B;2A:2B;');
2760+
}));
2761+
2762+
27502763
it('should group on $root compile function', inject(function($compile, $rootScope) {
27512764
$rootScope.show = false;
27522765
element = $compile(

0 commit comments

Comments
 (0)