Skip to content

Commit c70913b

Browse files
committed
fix(hmr): handle text node creation during HMR updates for cached nodes
1 parent 25ebe3a commit c70913b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/runtime-core/src/renderer.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,14 @@ function baseCreateRenderer(
498498
anchor,
499499
)
500500
} else {
501-
const el = (n2.el = n1.el!)
501+
let el = (n2.el = n1.el!)
502502
if (n2.children !== n1.children) {
503+
// we don't inherit text node for cached text nodes in `traverseStaticChildren`
504+
// but it maybe changed during HMR updates, so we need to handle this case by
505+
// creating a new text node.
506+
if (__DEV__ && isHmrUpdating && n2.patchFlag === PatchFlags.CACHED) {
507+
el = hostCreateText(n2.children as string)
508+
}
503509
hostSetText(el, n2.children as string)
504510
}
505511
}

0 commit comments

Comments
 (0)