@@ -56,8 +56,9 @@ void main() {
56
56
..bind (Parent , toValue: null )
57
57
..bind (Child )
58
58
..bind (ChildTemplateComponent )
59
- ..bind (InjectorDependentComponent )
60
- ..bind (TranscludeChildrenWithAttributeDirective );
59
+ ..bind (TranscludeChildrenWithAttributeDirective )
60
+ ..bind (LoggedBinding )
61
+ ..bind (InjectorDependentComponent );
61
62
});
62
63
63
64
beforeEach ((TestBed tb) => _ = tb);
@@ -187,6 +188,13 @@ void main() {
187
188
expect (log).toEqual (['OneOfTwo' , 'TwoOfTwo' ]);
188
189
});
189
190
191
+ it ('should not call bindings that are not present' , async ((Logger log) {
192
+ var element = _.compile ('<log-bind></log-bind>' );
193
+ _.rootScope.apply ();
194
+ expect (log.length).toEqual (0 );
195
+ }));
196
+
197
+
190
198
it ('should compile a directive that ignores children' , (Logger log) {
191
199
// The ng-repeat comes first, so it is not ignored, but the children *are*
192
200
var element = _.compile ('<div ng-repeat="i in [1,2]" ignore-children><div two-directives></div></div>' );
@@ -298,6 +306,7 @@ void main() {
298
306
..bind (ConditionalContentComponent )
299
307
..bind (ExprAttrComponent )
300
308
..bind (LogElementComponent )
309
+ ..bind (LoggedBinding )
301
310
..bind (SayHelloFormatter )
302
311
..bind (OuterComponent )
303
312
..bind (InnerComponent )
@@ -729,7 +738,6 @@ void main() {
729
738
component.expr = 'angular' ;
730
739
_.rootScope.apply ();
731
740
expect (_.rootScope.context['name' ]).toEqual ('angular' );
732
-
733
741
expect (_.rootScope.context['done' ]).toEqual (false );
734
742
component.onDone ();
735
743
expect (_.rootScope.context['done' ]).toEqual (true );
@@ -1716,3 +1724,17 @@ class InnerInnerComponent {
1716
1724
)
1717
1725
class TemplateUrlComponent {
1718
1726
}
1727
+
1728
+ @Component (
1729
+ selector: 'log-bind' ,
1730
+ map: const {
1731
+ 'optional-one' : '=>optional' ,
1732
+ 'optional-two' : '<=>optional' ,
1733
+ 'optional-once' : '=>!optional' ,
1734
+ }
1735
+ )
1736
+ class LoggedBinding {
1737
+ Logger logger;
1738
+ LoggedBinding (this .logger);
1739
+ set optional (input) => logger (input);
1740
+ }
0 commit comments