Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 84ded8c

Browse files
committed
test(compiler): Add a test for IGNORE_CHILDREN
1 parent 0b4c0a0 commit 84ded8c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/core_dom/compiler.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class Compiler {
3131
NgAnnotation annotation = directiveRef.annotation;
3232
var blockFactory = null;
3333

34+
// The first non-"compile_children" directive wins. Since directives are
35+
// sorted, TRANSCLUDE_CHILDREN wins if any directive has TRANSCLUDE_CHILDREN
3436
if (annotation.children != children &&
3537
children == NgAnnotation.COMPILE_CHILDREN) {
3638
children = annotation.children;

test/core_dom/compiler_spec.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ void main() {
1616
..type(PublishTypesAttrDirective)
1717
..type(PaneComponent)
1818
..type(SimpleTranscludeInAttachAttrDirective)
19+
..type(IgnoreChildrenDirective)
1920
..type(IncludeTranscludeAttrDirective)
2021
..type(LocalAttrDirective)
2122
..type(OneOfTwoDirectives)
@@ -138,6 +139,18 @@ void main() {
138139
expect(log).toEqual(['OneOfTwo', 'TwoOfTwo']);
139140
}));
140141

142+
it('should compile a directive that ignores children', inject((Logger log) {
143+
// The ng-repeat comes first, so it is not ignored, but the children *are*
144+
var element = $('<div ng-repeat="i in [1,2]" ignore-children><div two-directives></div></div>');
145+
var template = $compile(element, directives);
146+
147+
template(injector, element);
148+
rootScope.apply();
149+
150+
expect(log).toEqual(['Ignore', 'Ignore']);
151+
}));
152+
153+
141154
describe("interpolation", () {
142155
it('should interpolate attribute nodes', inject(() {
143156
var element = $('<div test="{{name}}"></div>');
@@ -670,6 +683,16 @@ class TwoOfTwoDirectives {
670683
}
671684
}
672685

686+
@NgDirective(
687+
selector: '[ignore-children]',
688+
children: NgAnnotation.IGNORE_CHILDREN
689+
)
690+
class IgnoreChildrenDirective {
691+
IgnoreChildrenDirective(Logger log) {
692+
log('Ignore');
693+
}
694+
}
695+
673696
class PublishTypesDirectiveSuperType {
674697
}
675698

0 commit comments

Comments
 (0)