@@ -67,21 +67,6 @@ class DebugRenderTreeDelegate extends JitRenderDelegate {
67
67
68
68
this . registry . register ( 'component' , name , definition ) ;
69
69
}
70
-
71
- registerCustomModifier ( name : string ) {
72
- const r = setModifierManager (
73
- ( ) => ( {
74
- capabilities : modifierCapabilities ( '3.22' ) ,
75
- createModifier ( ) { } ,
76
- installModifier ( ) { } ,
77
- updateModifier ( ) { } ,
78
- destroyModifier ( ) { } ,
79
- } ) ,
80
- class DidInsertModifier { }
81
- ) ;
82
- this . registry . register ( 'modifier' , name , r ) ;
83
- return r ;
84
- }
85
70
}
86
71
87
72
class DebugRenderTreeTest extends RenderTest {
@@ -342,71 +327,81 @@ class DebugRenderTreeTest extends RenderTest {
342
327
] ,
343
328
} ,
344
329
] ,
345
- }
330
+ } ,
346
331
] ) ;
347
332
}
348
333
349
334
@test modifiers ( ) {
350
335
this . registerComponent ( 'Glimmer' , 'HelloWorld' , 'Hello World' ) ;
351
336
const didInsert = ( ) => null ;
352
- this . registerModifier (
353
- 'did-insert' ,
354
- class {
355
- element ?: SimpleElement ;
356
- didInsertElement ( ) { }
357
- didUpdate ( ) { }
358
- willDestroyElement ( ) { }
359
- }
337
+
338
+ class DidInsertModifier {
339
+ element ?: SimpleElement ;
340
+ didInsertElement ( ) { }
341
+ didUpdate ( ) { }
342
+ willDestroyElement ( ) { }
343
+ }
344
+
345
+ this . registerModifier ( 'did-insert' , DidInsertModifier ) ;
346
+
347
+ class MyCustomModifier { }
348
+
349
+ setModifierManager (
350
+ ( ) => ( {
351
+ capabilities : modifierCapabilities ( '3.22' ) ,
352
+ createModifier ( ) {
353
+ return new MyCustomModifier ( ) ;
354
+ } ,
355
+ installModifier ( ) { } ,
356
+ updateModifier ( ) { } ,
357
+ destroyModifier ( ) { } ,
358
+ } ) ,
359
+ MyCustomModifier
360
360
) ;
361
- const modifier = this . defineModifier ( 'did-update' ) ;
361
+
362
+ const foo = Symbol ( 'foo' ) ;
363
+ const bar = Symbol ( 'bar' ) ;
362
364
363
365
this . render (
364
- `<div {{on 'click' this.didInsert}} {{did-insert this.didInsert}} {{did-update this.didInsert }} {{this.modifier this.didInsert }}
366
+ `<div {{on 'click' this.didInsert}} {{did-insert this.foo bar= this.bar }} {{this.modifier this.bar foo=this.foo }}
365
367
><HelloWorld />
366
368
{{~#if this.more~}}
367
- <div {{on 'click' this.didInsert}}></div>
369
+ <div {{on 'click' this.didInsert passive=true }}></div>
368
370
{{~/if~}}
369
371
</div>` ,
370
372
{
371
373
didInsert : didInsert ,
372
- modifier : modifier ,
374
+ modifier : MyCustomModifier ,
375
+ foo,
376
+ bar,
373
377
more : false ,
374
378
}
375
379
) ;
376
380
377
381
this . assertRenderTree ( [
378
- {
379
- type : 'modifier' ,
380
- name : 'did-update' ,
381
- args : { positional : [ didInsert ] , named : { } } ,
382
- instance : ( instance : any ) => typeof instance . installModifier === 'function' ,
383
- template : null ,
384
- bounds : this . nodeBounds ( this . element . firstChild ) ,
385
- children : [ ] ,
386
- } ,
387
382
{
388
383
type : 'modifier' ,
389
384
name : 'on' ,
390
385
args : { positional : [ 'click' , didInsert ] , named : { } } ,
391
- instance : ( instance : any ) => typeof instance === 'object' ,
386
+ instance : null ,
392
387
template : null ,
393
388
bounds : this . nodeBounds ( this . element . firstChild ) ,
394
389
children : [ ] ,
395
390
} ,
396
391
{
397
392
type : 'modifier' ,
398
393
name : 'DidInsertModifier' ,
399
- args : { positional : [ didInsert ] , named : { } } ,
400
- instance : ( instance : any ) => typeof instance . installModifier === 'function' ,
394
+ args : { positional : [ foo ] , named : { bar } } ,
395
+ instance : ( instance : unknown ) => instance instanceof DidInsertModifier ,
401
396
template : null ,
402
397
bounds : this . nodeBounds ( this . element . firstChild ) ,
403
398
children : [ ] ,
404
399
} ,
405
400
{
406
401
type : 'modifier' ,
407
- name : 'did-insert ' ,
408
- args : { positional : [ didInsert ] , named : { } } ,
409
- instance : ( instance : any ) => typeof instance . install === 'function' ,
402
+ name : 'MyCustomModifier ' ,
403
+ args : { positional : [ bar ] , named : { foo } } ,
404
+ instance : ( instance : unknown ) => instance instanceof MyCustomModifier ,
410
405
template : null ,
411
406
bounds : this . nodeBounds ( this . element . firstChild ) ,
412
407
children : [ ] ,
@@ -431,34 +426,25 @@ class DebugRenderTreeTest extends RenderTest {
431
426
type : 'modifier' ,
432
427
name : 'on' ,
433
428
args : { positional : [ 'click' , didInsert ] , named : { } } ,
434
- instance : ( instance : any ) => typeof instance === 'object' ,
435
- template : null ,
436
- bounds : this . nodeBounds ( this . element . firstChild ) ,
437
- children : [ ] ,
438
- } ,
439
- {
440
- type : 'modifier' ,
441
- name : 'did-update' ,
442
- args : { positional : [ didInsert ] , named : { } } ,
443
- instance : ( instance : any ) => typeof instance . installModifier === 'function' ,
429
+ instance : null ,
444
430
template : null ,
445
431
bounds : this . nodeBounds ( this . element . firstChild ) ,
446
432
children : [ ] ,
447
433
} ,
448
434
{
449
435
type : 'modifier' ,
450
436
name : 'DidInsertModifier' ,
451
- args : { positional : [ didInsert ] , named : { } } ,
452
- instance : ( instance : any ) => typeof instance . installModifier === 'function' ,
437
+ args : { positional : [ foo ] , named : { bar } } ,
438
+ instance : ( instance : unknown ) => instance instanceof DidInsertModifier ,
453
439
template : null ,
454
440
bounds : this . nodeBounds ( this . element . firstChild ) ,
455
441
children : [ ] ,
456
442
} ,
457
443
{
458
444
type : 'modifier' ,
459
- name : 'did-insert ' ,
460
- args : { positional : [ didInsert ] , named : { } } ,
461
- instance : ( instance : any ) => typeof instance . install === 'function' ,
445
+ name : 'MyCustomModifier ' ,
446
+ args : { positional : [ bar ] , named : { foo } } ,
447
+ instance : ( instance : unknown ) => instance instanceof MyCustomModifier ,
462
448
template : null ,
463
449
bounds : this . nodeBounds ( this . element . firstChild ) ,
464
450
children : [ ] ,
@@ -475,8 +461,8 @@ class DebugRenderTreeTest extends RenderTest {
475
461
{
476
462
type : 'modifier' ,
477
463
name : 'on' ,
478
- args : { positional : [ 'click' , didInsert ] , named : { } } ,
479
- instance : ( instance : any ) => typeof instance === 'object' ,
464
+ args : { positional : [ 'click' , didInsert ] , named : { passive : true } } ,
465
+ instance : null ,
480
466
template : null ,
481
467
bounds : this . nodeBounds ( this . element . firstChild ! . lastChild ) ,
482
468
children : [ ] ,
@@ -488,38 +474,29 @@ class DebugRenderTreeTest extends RenderTest {
488
474
} ) ;
489
475
490
476
this . assertRenderTree ( [
491
- {
492
- type : 'modifier' ,
493
- name : 'did-update' ,
494
- args : { positional : [ didInsert ] , named : { } } ,
495
- instance : ( instance : any ) => typeof instance . installModifier === 'function' ,
496
- template : null ,
497
- bounds : this . nodeBounds ( this . element . firstChild ) ,
498
- children : [ ] ,
499
- } ,
500
477
{
501
478
type : 'modifier' ,
502
479
name : 'on' ,
503
480
args : { positional : [ 'click' , didInsert ] , named : { } } ,
504
- instance : ( instance : any ) => typeof instance === 'object' ,
481
+ instance : null ,
505
482
template : null ,
506
483
bounds : this . nodeBounds ( this . element . firstChild ) ,
507
484
children : [ ] ,
508
485
} ,
509
486
{
510
487
type : 'modifier' ,
511
488
name : 'DidInsertModifier' ,
512
- args : { positional : [ didInsert ] , named : { } } ,
513
- instance : ( instance : any ) => typeof instance . installModifier === 'function' ,
489
+ args : { positional : [ foo ] , named : { bar } } ,
490
+ instance : ( instance : unknown ) => instance instanceof DidInsertModifier ,
514
491
template : null ,
515
492
bounds : this . nodeBounds ( this . element . firstChild ) ,
516
493
children : [ ] ,
517
494
} ,
518
495
{
519
496
type : 'modifier' ,
520
- name : 'did-insert ' ,
521
- args : { positional : [ didInsert ] , named : { } } ,
522
- instance : ( instance : any ) => typeof instance . install === 'function' ,
497
+ name : 'MyCustomModifier ' ,
498
+ args : { positional : [ bar ] , named : { foo } } ,
499
+ instance : ( instance : unknown ) => instance instanceof MyCustomModifier ,
523
500
template : null ,
524
501
bounds : this . nodeBounds ( this . element . firstChild ) ,
525
502
children : [ ] ,
@@ -724,10 +701,6 @@ class DebugRenderTreeTest extends RenderTest {
724
701
assert . deepEqual ( this . delegate . getCapturedRenderTree ( ) , [ ] , 'there was no output' ) ;
725
702
}
726
703
727
- defineModifier ( name : string ) {
728
- return this . delegate . registerCustomModifier ( name ) ;
729
- }
730
-
731
704
nodeBounds ( _node : SimpleNode | null ) : CapturedBounds {
732
705
let node = expect ( _node , 'BUG: Expected node' ) ;
733
706
0 commit comments