mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-24 13:53:43 +00:00
fix($compile): support multi-element group over text nodes
This commit is contained in:
parent
6b12432729
commit
b28f96949a
2 changed files with 17 additions and 2 deletions
|
|
@ -591,8 +591,10 @@ function $CompileProvider($provide) {
|
||||||
if (!node) {
|
if (!node) {
|
||||||
throw ngError(51, "Unterminated attribute, found '{0}' but no matching '{1}' found.", attrStart, attrEnd);
|
throw ngError(51, "Unterminated attribute, found '{0}' but no matching '{1}' found.", attrStart, attrEnd);
|
||||||
}
|
}
|
||||||
if (node.hasAttribute(attrStart)) depth++;
|
if (node.nodeType == 1 /** Element **/) {
|
||||||
if (node.hasAttribute(attrEnd)) depth--;
|
if (node.hasAttribute(attrStart)) depth++;
|
||||||
|
if (node.hasAttribute(attrEnd)) depth--;
|
||||||
|
}
|
||||||
nodes.push(node);
|
nodes.push(node);
|
||||||
node = node.nextSibling;
|
node = node.nextSibling;
|
||||||
} while (depth > 0);
|
} while (depth > 0);
|
||||||
|
|
|
||||||
|
|
@ -2747,6 +2747,19 @@ describe('$compile', function() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should support grouping over text nodes', inject(function($compile, $rootScope) {
|
||||||
|
$rootScope.show = false;
|
||||||
|
element = $compile(
|
||||||
|
'<div>' +
|
||||||
|
'<span ng-repeat-start="i in [1,2]">{{i}}A</span>' +
|
||||||
|
':' + // Important: proves that we can iterate over non-elements
|
||||||
|
'<span ng-repeat-end>{{i}}B;</span>' +
|
||||||
|
'</div>')($rootScope);
|
||||||
|
$rootScope.$digest();
|
||||||
|
expect(element.text()).toEqual('1A:1B;2A:2B;');
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should group on $root compile function', inject(function($compile, $rootScope) {
|
it('should group on $root compile function', inject(function($compile, $rootScope) {
|
||||||
$rootScope.show = false;
|
$rootScope.show = false;
|
||||||
element = $compile(
|
element = $compile(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue