expect((container as any)._vnode).toBe(null)
})
+ // #6637
+ test('stringified root fragment', () => {
+ mountWithHydration(`<!--[--><div></div><!--]-->`, () =>
+ createStaticVNode(`<div></div>`, 1)
+ )
+ expect(`mismatch`).not.toHaveBeenWarned()
+ })
+
describe('mismatch handling', () => {
test('text node', () => {
const { container } = mountWithHydration(`foo`, () => 'bar')
)
const { type, ref, shapeFlag, patchFlag } = vnode
- const domType = node.nodeType
+ let domType = node.nodeType
vnode.el = node
if (patchFlag === PatchFlags.BAIL) {
}
break
case Static:
- if (domType !== DOMNodeTypes.ELEMENT && domType !== DOMNodeTypes.TEXT) {
- nextNode = onMismatch()
- } else {
+ if (isFragmentStart) {
+ // entire template is static but SSRed as a fragment
+ node = nextSibling(node)!
+ domType = node.nodeType
+ }
+ if (domType === DOMNodeTypes.ELEMENT || domType === DOMNodeTypes.TEXT) {
// determine anchor, adopt content
nextNode = node
// if the static vnode has its content stripped during build,
}
nextNode = nextSibling(nextNode)!
}
- return nextNode
+ return isFragmentStart ? nextSibling(nextNode) : nextNode
+ } else {
+ onMismatch()
}
break
case Fragment: