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

Commit 30cea03

Browse files
committed
test(compiler): Components should not pass null to inner directives.
1 parent b54d94b commit 30cea03

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/core_dom/compiler_spec.dart

+33
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ void main() {
323323
..bind(LogElementComponent)
324324
..bind(SayHelloFormatter)
325325
..bind(OneTimeDecorator)
326+
..bind(OnceInside)
326327
..bind(OuterShadowless)
327328
..bind(InnerShadowy);
328329
});
@@ -465,6 +466,22 @@ void main() {
465466
expect(element).toHaveText('inside ');
466467
}));
467468

469+
it('should not pass null to a inner directives', async((Logger logger) {
470+
_.compile('<div>'
471+
'<once-inside ng-repeat="x in nn" v="b"></once-inside>'
472+
'</div>');
473+
474+
_.rootScope.context['nn'] = [1];
475+
_.rootScope.apply();
476+
microLeap();
477+
478+
_.rootScope.context['nn'].add(2);
479+
_.rootScope.apply();
480+
microLeap();
481+
482+
expect(logger.contains(null)).toBeFalsy();
483+
}));
484+
468485
it('should create a component with I/O', async(() {
469486
_.compile(r'<div><io attr="A" expr="name" ondone="done=true"></io></div>');
470487
microLeap();
@@ -880,6 +897,8 @@ void main() {
880897
_.rootScope.apply();
881898
expect(logger).toEqual([1, null, 8]);
882899
});
900+
901+
883902
});
884903
});
885904

@@ -1520,3 +1539,17 @@ class OuterShadowless {}
15201539
selector: 'inner-shadowy',
15211540
template: '<content></content>')
15221541
class InnerShadowy {}
1542+
1543+
@Component(
1544+
selector: 'once-inside',
1545+
template: '<div one-time="ctrl.ot"></div>',
1546+
publishAs: 'ctrl'
1547+
)
1548+
class OnceInside {
1549+
var ot;
1550+
1551+
Logger log;
1552+
@NgAttr("v")
1553+
set v(x) { log(x); ot = "($x)"; }
1554+
OnceInside(Logger this.log) { log('!'); }
1555+
}

0 commit comments

Comments
 (0)