@@ -495,25 +495,14 @@ export function createRenderer<
495
495
}
496
496
497
497
if ( dynamicChildren != null ) {
498
- // children fast path
499
- const oldDynamicChildren = n1 . dynamicChildren !
500
- for ( let i = 0 ; i < dynamicChildren . length ; i ++ ) {
501
- const oldVNode = oldDynamicChildren [ i ]
502
- patch (
503
- oldVNode ,
504
- dynamicChildren [ i ] ,
505
- // in the case of a Fragment, we need to provide the actual parent
506
- // of the Fragment itself so it can move its children. In other cases,
507
- // the parent container is not actually used so we just pass the
508
- // block element here to avoid a DOM parentNode call.
509
- oldVNode . type === Fragment ? hostParentNode ( oldVNode . el ! ) ! : el ,
510
- null ,
511
- parentComponent ,
512
- parentSuspense ,
513
- isSVG ,
514
- true
515
- )
516
- }
498
+ patchBlockChildren (
499
+ n1 . dynamicChildren ! ,
500
+ dynamicChildren ,
501
+ el ,
502
+ parentComponent ,
503
+ parentSuspense ,
504
+ isSVG
505
+ )
517
506
} else if ( ! optimized ) {
518
507
// full diff
519
508
patchChildren ( n1 , n2 , el , null , parentComponent , parentSuspense , isSVG )
@@ -526,6 +515,36 @@ export function createRenderer<
526
515
}
527
516
}
528
517
518
+ // The fast path for blocks.
519
+ function patchBlockChildren (
520
+ oldChildren : HostVNode [ ] ,
521
+ newChildren : HostVNode [ ] ,
522
+ fallbackContainer : HostElement ,
523
+ parentComponent : ComponentInternalInstance | null ,
524
+ parentSuspense : HostSuspenseBoundary | null ,
525
+ isSVG : boolean
526
+ ) {
527
+ for ( let i = 0 ; i < newChildren . length ; i ++ ) {
528
+ const oldVNode = oldChildren [ i ]
529
+ patch (
530
+ oldVNode ,
531
+ newChildren [ i ] ,
532
+ // in the case of a Fragment, we need to provide the actual parent
533
+ // of the Fragment itself so it can move its children. In other cases,
534
+ // the parent container is not actually used so we just pass the
535
+ // block element here to avoid a DOM parentNode call.
536
+ oldVNode . type === Fragment
537
+ ? hostParentNode ( oldVNode . el ! ) !
538
+ : fallbackContainer ,
539
+ null ,
540
+ parentComponent ,
541
+ parentSuspense ,
542
+ isSVG ,
543
+ true
544
+ )
545
+ }
546
+ }
547
+
529
548
function patchProps (
530
549
el : HostElement ,
531
550
vnode : HostVNode ,
@@ -654,6 +673,16 @@ export function createRenderer<
654
673
const target = ( n2 . target = n1 . target ) !
655
674
if ( patchFlag === PatchFlags . TEXT ) {
656
675
hostSetElementText ( target , children as string )
676
+ } else if ( n2 . dynamicChildren ) {
677
+ // fast path when the portal happens to be a block root
678
+ patchBlockChildren (
679
+ n1 . dynamicChildren ! ,
680
+ n2 . dynamicChildren ,
681
+ container ,
682
+ parentComponent ,
683
+ parentSuspense ,
684
+ isSVG
685
+ )
657
686
} else if ( ! optimized ) {
658
687
patchChildren (
659
688
n1 ,
0 commit comments