(
node: Node,
vnode: VNode,
parentComponent: ComponentInternalInstance | null,
parentSuspense: SuspenseBoundary | null,
slotScopeIds: string[] | null,
optimized = false,
)
| 135 | } |
| 136 | |
| 137 | const hydrateNode = ( |
| 138 | node: Node, |
| 139 | vnode: VNode, |
| 140 | parentComponent: ComponentInternalInstance | null, |
| 141 | parentSuspense: SuspenseBoundary | null, |
| 142 | slotScopeIds: string[] | null, |
| 143 | optimized = false, |
| 144 | ): Node | null => { |
| 145 | optimized = optimized || !!vnode.dynamicChildren |
| 146 | const isFragmentStart = isComment(node) && node.data === '[' |
| 147 | const onMismatch = () => |
| 148 | handleMismatch( |
| 149 | node, |
| 150 | vnode, |
| 151 | parentComponent, |
| 152 | parentSuspense, |
| 153 | slotScopeIds, |
| 154 | isFragmentStart, |
| 155 | ) |
| 156 | |
| 157 | const { type, ref, shapeFlag, patchFlag } = vnode |
| 158 | let domType = node.nodeType |
| 159 | vnode.el = node |
| 160 | |
| 161 | if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { |
| 162 | def(node, '__vnode', vnode, true) |
| 163 | def(node, '__vueParentComponent', parentComponent, true) |
| 164 | } |
| 165 | |
| 166 | if (patchFlag === PatchFlags.BAIL) { |
| 167 | optimized = false |
| 168 | vnode.dynamicChildren = null |
| 169 | } |
| 170 | |
| 171 | let nextNode: Node | null = null |
| 172 | switch (type) { |
| 173 | case Text: |
| 174 | if (domType !== DOMNodeTypes.TEXT) { |
| 175 | // #5728 empty text node inside a slot can cause hydration failure |
| 176 | // because the server rendered HTML won't contain a text node |
| 177 | if (vnode.children === '') { |
| 178 | insert((vnode.el = createText('')), parentNode(node)!, node) |
| 179 | nextNode = node |
| 180 | } else { |
| 181 | nextNode = onMismatch() |
| 182 | } |
| 183 | } else { |
| 184 | if ((node as Text).data !== vnode.children) { |
| 185 | ;(__DEV__ || __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) && |
| 186 | warn( |
| 187 | `Hydration text mismatch in`, |
| 188 | node.parentNode, |
| 189 | `\n - rendered on server: ${JSON.stringify( |
| 190 | (node as Text).data, |
| 191 | )}` + |
| 192 | `\n - expected on client: ${JSON.stringify(vnode.children)}`, |
| 193 | ) |
| 194 | logMismatchError() |
no test coverage detected