File tree 2 files changed +18
-5
lines changed
2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -982,6 +982,14 @@ describe('SSR hydration', () => {
982
982
expect ( ( container as any ) . _vnode ) . toBe ( null )
983
983
} )
984
984
985
+ // #6637
986
+ test ( 'stringified root fragment' , ( ) => {
987
+ mountWithHydration ( `<!--[--><div></div><!--]-->` , ( ) =>
988
+ createStaticVNode ( `<div></div>` , 1 )
989
+ )
990
+ expect ( `mismatch` ) . not . toHaveBeenWarned ( )
991
+ } )
992
+
985
993
describe ( 'mismatch handling' , ( ) => {
986
994
test ( 'text node' , ( ) => {
987
995
const { container } = mountWithHydration ( `foo` , ( ) => 'bar' )
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export function createHydrationFunctions(
108
108
)
109
109
110
110
const { type, ref, shapeFlag, patchFlag } = vnode
111
- const domType = node . nodeType
111
+ let domType = node . nodeType
112
112
vnode . el = node
113
113
114
114
if ( patchFlag === PatchFlags . BAIL ) {
@@ -150,9 +150,12 @@ export function createHydrationFunctions(
150
150
}
151
151
break
152
152
case Static :
153
- if ( domType !== DOMNodeTypes . ELEMENT && domType !== DOMNodeTypes . TEXT ) {
154
- nextNode = onMismatch ( )
155
- } else {
153
+ if ( isFragmentStart ) {
154
+ // entire template is static but SSRed as a fragment
155
+ node = nextSibling ( node ) !
156
+ domType = node . nodeType
157
+ }
158
+ if ( domType === DOMNodeTypes . ELEMENT || domType === DOMNodeTypes . TEXT ) {
156
159
// determine anchor, adopt content
157
160
nextNode = node
158
161
// if the static vnode has its content stripped during build,
@@ -169,7 +172,9 @@ export function createHydrationFunctions(
169
172
}
170
173
nextNode = nextSibling ( nextNode ) !
171
174
}
172
- return nextNode
175
+ return isFragmentStart ? nextSibling ( nextNode ) : nextNode
176
+ } else {
177
+ onMismatch ( )
173
178
}
174
179
break
175
180
case Fragment :
You can’t perform that action at this time.
0 commit comments