|
|
@@ -531,7 +531,27 @@ export function createHydrationFunctions(
|
|
|
const vnode = optimized
|
|
|
? children[i]
|
|
|
: (children[i] = normalizeVNode(children[i]))
|
|
|
+ const isText = vnode.type === Text
|
|
|
if (node) {
|
|
|
+ if (isText && !optimized) {
|
|
|
+ // #7285 possible consecutive text vnodes from manual render fns or
|
|
|
+ // JSX-compiled fns, but on the client the browser parses only 1 text
|
|
|
+ // node.
|
|
|
+ // look ahead for next possible text vnode
|
|
|
+ let next = children[i + 1]
|
|
|
+ if (next && (next = normalizeVNode(next)).type === Text) {
|
|
|
+ // create an extra TextNode on the client for the next vnode to
|
|
|
+ // adopt
|
|
|
+ insert(
|
|
|
+ createText(
|
|
|
+ (node as Text).data.slice((vnode.children as string).length),
|
|
|
+ ),
|
|
|
+ container,
|
|
|
+ nextSibling(node),
|
|
|
+ )
|
|
|
+ ;(node as Text).data = vnode.children as string
|
|
|
+ }
|
|
|
+ }
|
|
|
node = hydrateNode(
|
|
|
node,
|
|
|
vnode,
|
|
|
@@ -540,7 +560,7 @@ export function createHydrationFunctions(
|
|
|
slotScopeIds,
|
|
|
optimized,
|
|
|
)
|
|
|
- } else if (vnode.type === Text && !vnode.children) {
|
|
|
+ } else if (isText && !vnode.children) {
|
|
|
// #7215 create a TextNode for empty text node
|
|
|
// because server rendered HTML won't contain a text node
|
|
|
insert((vnode.el = createText('')), container)
|