Skip to content

Commit 5f560a4

Browse files
committed
fix client-side hydration check for v-html/v-text
1 parent 9c4bf35 commit 5f560a4

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/core/vdom/patch.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -373,20 +373,24 @@ export function createPatchFunction (backend) {
373373
}
374374

375375
function assertNodeMatch (node, vnode) {
376-
if (vnode.tag) {
377-
if (vnode.tag.indexOf('vue-component') === 0) {
378-
return true
379-
} else {
380-
const childNodes = nodeOps.childNodes(node)
381-
return vnode.tag === nodeOps.tagName(node).toLowerCase() && (
382-
vnode.children
383-
? vnode.children.length === childNodes.length
384-
: childNodes.length === 0
385-
)
386-
}
376+
let match = true
377+
if (!node) {
378+
match = false
379+
} else if (vnode.tag) {
380+
match =
381+
vnode.tag.indexOf('vue-component') === 0 ||
382+
vnode.tag === nodeOps.tagName(node).toLowerCase()
387383
} else {
388-
return _toString(vnode.text) === node.data
384+
match = _toString(vnode.text) === node.data
385+
}
386+
if (process.env.NODE_ENV !== 'production' && !match) {
387+
warn(
388+
'The client-side rendered virtual DOM tree is not matching ' +
389+
'server-rendered content. Bailing hydration and performing ' +
390+
'full client-side render.'
391+
)
389392
}
393+
return match
390394
}
391395

392396
return function patch (oldVnode, vnode, hydrating, removeOnly) {
@@ -415,12 +419,6 @@ export function createPatchFunction (backend) {
415419
if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
416420
invokeInsertHook(vnode, insertedVnodeQueue, true)
417421
return oldVnode
418-
} else if (process.env.NODE_ENV !== 'production') {
419-
warn(
420-
'The client-side rendered virtual DOM tree is not matching ' +
421-
'server-rendered content. Bailing hydration and performing ' +
422-
'full client-side render.'
423-
)
424422
}
425423
}
426424
// either not server-rendered, or hydration failed.

0 commit comments

Comments
 (0)