@@ -475,4 +475,57 @@ describe('renderer: teleport', () => {
475
475
expect ( dir . mounted ) . toHaveBeenCalledTimes ( 1 )
476
476
expect ( dir . unmounted ) . toHaveBeenCalledTimes ( 1 )
477
477
} )
478
+
479
+ // #7835
480
+ test ( `ensure that target changes when disabled are updated correctly when enabled` , async ( ) => {
481
+ const root = nodeOps . createElement ( 'div' )
482
+ const target1 = nodeOps . createElement ( 'div' )
483
+ const target2 = nodeOps . createElement ( 'div' )
484
+ const target3 = nodeOps . createElement ( 'div' )
485
+ const target = ref ( target1 )
486
+ const disabled = ref ( true )
487
+
488
+ const App = {
489
+ setup ( ) {
490
+ return ( ) =>
491
+ h ( Fragment , [
492
+ h (
493
+ Teleport ,
494
+ { to : target . value , disabled : disabled . value } ,
495
+ h ( 'div' , 'teleported' )
496
+ )
497
+ ] )
498
+ }
499
+ }
500
+ render ( h ( App ) , root )
501
+ disabled . value = false
502
+ await nextTick ( )
503
+ expect ( serializeInner ( target1 ) ) . toMatchInlineSnapshot (
504
+ `"<div>teleported</div>"`
505
+ )
506
+ expect ( serializeInner ( target2 ) ) . toMatchInlineSnapshot ( `""` )
507
+ expect ( serializeInner ( target3 ) ) . toMatchInlineSnapshot ( `""` )
508
+
509
+ disabled . value = true
510
+ await nextTick ( )
511
+ target . value = target2
512
+ await nextTick ( )
513
+ expect ( serializeInner ( target1 ) ) . toMatchInlineSnapshot ( `""` )
514
+ expect ( serializeInner ( target2 ) ) . toMatchInlineSnapshot ( `""` )
515
+ expect ( serializeInner ( target3 ) ) . toMatchInlineSnapshot ( `""` )
516
+
517
+ target . value = target3
518
+ await nextTick ( )
519
+ expect ( serializeInner ( target1 ) ) . toMatchInlineSnapshot ( `""` )
520
+ expect ( serializeInner ( target2 ) ) . toMatchInlineSnapshot ( `""` )
521
+ expect ( serializeInner ( target3 ) ) . toMatchInlineSnapshot ( `""` )
522
+
523
+ disabled . value = false
524
+ await nextTick ( )
525
+ expect ( serializeInner ( target1 ) ) . toMatchInlineSnapshot ( `""` )
526
+ expect ( serializeInner ( target2 ) ) . toMatchInlineSnapshot ( `""` )
527
+ expect ( serializeInner ( target3 ) ) . toMatchInlineSnapshot (
528
+ `"<div>teleported</div>"`
529
+ )
530
+ } )
478
531
} )
0 commit comments