File tree Expand file tree Collapse file tree 2 files changed +36
-14
lines changed Expand file tree Collapse file tree 2 files changed +36
-14
lines changed Original file line number Diff line number Diff line change @@ -1065,6 +1065,34 @@ describe('Vapor Mode hydration', () => {
10651065 ` ,
10661066 )
10671067 } )
1068+
1069+ test ( 'dynamic component fallback with dynamic slots' , async ( ) => {
1070+ const data = ref ( {
1071+ name : 'default' ,
1072+ msg : 'foo' ,
1073+ } )
1074+ const { container } = await testHydration (
1075+ `<template>
1076+ <component :is="'div'">
1077+ <template v-slot:[data.name]>
1078+ <span>{{ data.msg }}</span>
1079+ </template>
1080+ </component>
1081+ </template>` ,
1082+ { } ,
1083+ data ,
1084+ )
1085+
1086+ expect ( formatHtml ( container . innerHTML ) ) . toMatchInlineSnapshot (
1087+ `"<div><span>foo</span><!----></div><!--dynamic-component-->"` ,
1088+ )
1089+
1090+ data . value . msg = 'bar'
1091+ await nextTick ( )
1092+ expect ( formatHtml ( container . innerHTML ) ) . toMatchInlineSnapshot (
1093+ `"<div><span>bar</span><!----></div><!--dynamic-component-->"` ,
1094+ )
1095+ } )
10681096 } )
10691097
10701098 describe ( 'if' , ( ) => {
Original file line number Diff line number Diff line change @@ -665,22 +665,16 @@ export function createComponentWithFallback(
665665 setCurrentHydrationNode ( el . firstChild )
666666 }
667667 if ( rawSlots . $ ) {
668- const frag =
669- isHydrating || __DEV__
670- ? new DynamicFragment ( 'slot' )
671- : new DynamicFragment ( )
672-
668+ // ssr output does not contain the slot anchor, use an empty string
669+ // as the anchor label to avoid slot anchor search errors
670+ const frag = new DynamicFragment (
671+ isHydrating ? '' : __DEV__ ? 'slot' : undefined ,
672+ )
673673 renderEffect ( ( ) => frag . update ( getSlot ( rawSlots as RawSlots , 'default' ) ) )
674-
675- if ( ! isHydrating ) {
676- const scopeId = currentInstance ! . type . __scopeId
677- if ( scopeId ) setScopeId ( frag , [ `${ scopeId } -s` ] )
678- insert ( frag , el )
679- } else {
680- frag . hydrate ( )
681- }
674+ if ( ! isHydrating ) insert ( frag , el )
682675 } else {
683- insert ( getSlot ( rawSlots as RawSlots , 'default' ) ! ( ) , el )
676+ const block = getSlot ( rawSlots as RawSlots , 'default' ) ! ( )
677+ if ( ! isHydrating ) insert ( block , el )
684678 }
685679 if ( isHydrating ) {
686680 setCurrentHydrationNode ( nextNode )
You can’t perform that action at this time.
0 commit comments