@@ -191,22 +191,6 @@ export function main() {
191
191
} ) ;
192
192
} ) ) ;
193
193
194
- it ( 'should ignore bindings to unknown properties' ,
195
- inject ( [ TestBed , AsyncTestCompleter ] , ( tb : TestBed , async ) => {
196
- tb . overrideView ( MyComp ,
197
- new viewAnn . View ( { template : '<div unknown="{{ctxProp}}"></div>' } ) ) ;
198
-
199
- tb . createView ( MyComp , { context : ctx } )
200
- . then ( ( view ) => {
201
-
202
- ctx . ctxProp = 'Some value' ;
203
- view . detectChanges ( ) ;
204
- expect ( DOM . hasProperty ( view . rootNodes [ 0 ] , 'unknown' ) ) . toBeFalsy ( ) ;
205
-
206
- async . done ( ) ;
207
- } ) ;
208
- } ) ) ;
209
-
210
194
it ( 'should consume directive watch expression change.' ,
211
195
inject ( [ TestBed , AsyncTestCompleter ] , ( tb : TestBed , async ) => {
212
196
var tpl = '<div>' +
@@ -444,7 +428,7 @@ export function main() {
444
428
it ( 'should assign a directive to a var-' ,
445
429
inject ( [ TestBed , AsyncTestCompleter ] , ( tb : TestBed , async ) => {
446
430
tb . overrideView ( MyComp , new viewAnn . View ( {
447
- template : '<p><div [ export-dir] #localdir="dir"></div></p>' ,
431
+ template : '<p><div export-dir #localdir="dir"></div></p>' ,
448
432
directives : [ ExportDir ]
449
433
} ) ) ;
450
434
@@ -1146,7 +1130,7 @@ export function main() {
1146
1130
it ( 'should specify a location of an error that happened during change detection (element property)' ,
1147
1131
inject ( [ TestBed , AsyncTestCompleter ] , ( tb : TestBed , async ) => {
1148
1132
1149
- tb . overrideView ( MyComp , new viewAnn . View ( { template : '<div [prop ]="a.b"></div>' } ) ) ;
1133
+ tb . overrideView ( MyComp , new viewAnn . View ( { template : '<div [title ]="a.b"></div>' } ) ) ;
1150
1134
1151
1135
tb . createView ( MyComp , { context : ctx } )
1152
1136
. then ( ( view ) => {
@@ -1159,10 +1143,10 @@ export function main() {
1159
1143
it ( 'should specify a location of an error that happened during change detection (directive property)' ,
1160
1144
inject ( [ TestBed , AsyncTestCompleter ] , ( tb : TestBed , async ) => {
1161
1145
1162
- tb . overrideView (
1163
- MyComp ,
1164
- new viewAnn . View (
1165
- { template : '<child-cmp [prop]="a.b"></child-cmp>' , directives : [ ChildComp ] } ) ) ;
1146
+ tb . overrideView ( MyComp , new viewAnn . View ( {
1147
+ template : '<child-cmp [dir-prop]="a.b"></child-cmp>' ,
1148
+ directives : [ ChildComp ]
1149
+ } ) ) ;
1166
1150
1167
1151
tb . createView ( MyComp , { context : ctx } )
1168
1152
. then ( ( view ) => {
@@ -1207,6 +1191,30 @@ export function main() {
1207
1191
} ) ;
1208
1192
} ) ) ;
1209
1193
1194
+ describe ( 'Missing property bindings' , ( ) => {
1195
+ it ( 'should throw on bindings to unknown properties' ,
1196
+ inject ( [ TestBed , AsyncTestCompleter ] , ( tb : TestBed , async ) => {
1197
+ tb . overrideView ( MyComp ,
1198
+ new viewAnn . View ( { template : '<div unknown="{{ctxProp}}"></div>' } ) ) ;
1199
+
1200
+ PromiseWrapper . catchError ( tb . createView ( MyComp , { context : ctx } ) , ( e ) => {
1201
+ expect ( e . message ) . toEqual (
1202
+ `Can't bind to 'unknown' since it isn't a know property of the 'div' element` ) ;
1203
+ async . done ( ) ;
1204
+ return null ;
1205
+ } ) ;
1206
+ } ) ) ;
1207
+
1208
+ it ( 'should not throw for property binding to a non-existing property when there is a matching directive property' ,
1209
+ inject ( [ TestBed , AsyncTestCompleter ] , ( tb : TestBed , async ) => {
1210
+ tb . overrideView (
1211
+ MyComp ,
1212
+ new viewAnn . View (
1213
+ { template : '<div my-dir [elprop]="ctxProp"></div>' , directives : [ MyDir ] } ) ) ;
1214
+ tb . createView ( MyComp , { context : ctx } ) . then ( ( val ) => { async . done ( ) ; } ) ;
1215
+ } ) ) ;
1216
+ } ) ;
1217
+
1210
1218
// Disabled until a solution is found, refs:
1211
1219
// - https://github.com/angular/angular/issues/776
1212
1220
// - https://github.com/angular/angular/commit/81f3f32
@@ -1356,10 +1364,7 @@ class ComponentWithPipes {
1356
1364
prop : string ;
1357
1365
}
1358
1366
1359
- @Component ( {
1360
- selector : 'child-cmp' ,
1361
- appInjector : [ MyService ] ,
1362
- } )
1367
+ @Component ( { selector : 'child-cmp' , properties : [ 'dirProp' ] , appInjector : [ MyService ] } )
1363
1368
@View ( { directives : [ MyDir ] , template : '{{ctxProp}}' } )
1364
1369
@Injectable ( )
1365
1370
class ChildComp {
0 commit comments