@@ -315,11 +315,37 @@ if (hasDom) {
315
315
this . assertCounts ( { adds : 1 , removes : 0 } ) ;
316
316
}
317
317
318
+ @test
319
+ 'updates to a (remaining truthy) condition do not leave the element without an attached modifier' ( assert :
320
+ Assert ) {
321
+ let calledCount = 0 ;
322
+
323
+ this . render ( '<button {{on "click" this.callback}}>Click Me</button>' , {
324
+ callback ( ) {
325
+ calledCount ++ ;
326
+ } ,
327
+ condition : true ,
328
+ } ) ;
329
+
330
+ this . findButton ( ) . click ( ) ;
331
+ assert . strictEqual ( calledCount , 1 , 'callback is being invoked' ) ;
332
+
333
+ this . rerender ( { condition : true } ) ;
334
+
335
+ this . findButton ( ) . click ( ) ;
336
+ assert . strictEqual ( calledCount , 2 , 'callback is being invoked' ) ;
337
+
338
+ this . rerender ( { condition : true } ) ;
339
+
340
+ this . findButton ( ) . click ( ) ;
341
+ assert . strictEqual ( calledCount , 3 , 'callback is being invoked' ) ;
342
+ }
343
+
318
344
@test
319
345
'asserts when eventName is missing' ( assert : Assert ) {
320
346
assert . throws ( ( ) => {
321
347
this . render ( `<button {{on undefined this.callback}}>Click Me</button>` , {
322
- callback ( ) { } ,
348
+ callback ( ) { } ,
323
349
} ) ;
324
350
} , / Y o u m u s t p a s s a v a l i d D O M e v e n t n a m e a s t h e f i r s t a r g u m e n t t o t h e ` o n ` m o d i f i e r / u) ;
325
351
}
@@ -328,7 +354,7 @@ if (hasDom) {
328
354
'asserts when eventName is a bound undefined value' ( assert : Assert ) {
329
355
assert . throws ( ( ) => {
330
356
this . render ( `<button {{on this.someUndefinedThing this.callback}}>Click Me</button>` , {
331
- callback ( ) { } ,
357
+ callback ( ) { } ,
332
358
} ) ;
333
359
} , / Y o u m u s t p a s s a v a l i d D O M e v e n t n a m e a s t h e f i r s t a r g u m e n t t o t h e ` o n ` m o d i f i e r / u) ;
334
360
}
@@ -337,7 +363,7 @@ if (hasDom) {
337
363
'asserts when eventName is a function' ( assert : Assert ) {
338
364
assert . throws ( ( ) => {
339
365
this . render ( `<button {{on this.callback}}>Click Me</button>` , {
340
- callback ( ) { } ,
366
+ callback ( ) { } ,
341
367
} ) ;
342
368
} , / Y o u m u s t p a s s a v a l i d D O M e v e n t n a m e a s t h e f i r s t a r g u m e n t t o t h e ` o n ` m o d i f i e r / u) ;
343
369
}
@@ -384,7 +410,7 @@ if (hasDom) {
384
410
'asserts if more than 2 positional parameters are provided' ( assert : Assert ) {
385
411
assert . throws ( ( ) => {
386
412
this . render ( `<button {{on 'click' this.callback this.someArg}}>Click Me</button>` , {
387
- callback ( ) { } ,
413
+ callback ( ) { } ,
388
414
someArg : 'foo' ,
389
415
} ) ;
390
416
} , / Y o u c a n o n l y p a s s t w o p o s i t i o n a l a r g u m e n t s \( e v e n t n a m e a n d c a l l b a c k \) t o t h e ` o n ` m o d i f i e r , b u t y o u p r o v i d e d 3 . C o n s i d e r u s i n g t h e ` f n ` h e l p e r t o p r o v i d e a d d i t i o n a l a r g u m e n t s t o t h e ` o n ` c a l l b a c k ./ u) ;
0 commit comments