MCPcopy
hub / github.com/vuejs/core / handleMismatch

Function handleMismatch

packages/runtime-core/src/hydration.ts:686–745  ·  view source on GitHub ↗
(
    node: Node,
    vnode: VNode,
    parentComponent: ComponentInternalInstance | null,
    parentSuspense: SuspenseBoundary | null,
    slotScopeIds: string[] | null,
    isFragment: boolean,
  )

Source from the content-addressed store, hash-verified

684 }
685
686 const handleMismatch = (
687 node: Node,
688 vnode: VNode,
689 parentComponent: ComponentInternalInstance | null,
690 parentSuspense: SuspenseBoundary | null,
691 slotScopeIds: string[] | null,
692 isFragment: boolean,
693 ): Node | null => {
694 if (!isNodeMismatchAllowed(node, vnode)) {
695 ;(__DEV__ || __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) &&
696 warn(
697 `Hydration node mismatch:\n- rendered on server:`,
698 node,
699 node.nodeType === DOMNodeTypes.TEXT
700 ? `(text)`
701 : isComment(node) && node.data === '['
702 ? `(start of fragment)`
703 : ``,
704 `\n- expected on client:`,
705 vnode.type,
706 )
707 logMismatchError()
708 }
709
710 vnode.el = null
711
712 if (isFragment) {
713 // remove excessive fragment nodes
714 const end = locateClosingAnchor(node)
715 while (true) {
716 const next = nextSibling(node)
717 if (next && next !== end) {
718 remove(next)
719 } else {
720 break
721 }
722 }
723 }
724
725 const next = nextSibling(node)
726 const container = parentNode(node)!
727 remove(node)
728
729 patch(
730 null,
731 vnode,
732 container,
733 next,
734 parentComponent,
735 parentSuspense,
736 getContainerType(container),
737 slotScopeIds,
738 )
739 // the component vnode's el should be updated when a mismatch occurs.
740 if (parentComponent) {
741 parentComponent.vnode.el = vnode.el
742 updateHOCHostEl(parentComponent, vnode.el)
743 }

Callers 1

onMismatchFunction · 0.85

Calls 11

warnFunction · 0.90
updateHOCHostElFunction · 0.90
isNodeMismatchAllowedFunction · 0.85
logMismatchErrorFunction · 0.85
locateClosingAnchorFunction · 0.85
nextSiblingFunction · 0.85
parentNodeFunction · 0.85
patchFunction · 0.85
getContainerTypeFunction · 0.85
isCommentFunction · 0.70
removeFunction · 0.70

Tested by

no test coverage detected