Skip to content

Commit bf16a57

Browse files
committed
fix(runtime-core): handle static node move in production
1 parent 2a9ba0c commit bf16a57

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

packages/runtime-core/src/renderer.ts

+16-21
Original file line numberDiff line numberDiff line change
@@ -632,32 +632,28 @@ function baseCreateRenderer(
632632
}
633633
}
634634

635-
/**
636-
* Dev / HMR only
637-
*/
638635
const moveStaticNode = (
639-
vnode: VNode,
636+
{ el, anchor }: VNode,
640637
container: RendererElement,
641-
anchor: RendererNode | null
638+
nextSibling: RendererNode | null
642639
) => {
643-
let cur = vnode.el
644-
const end = vnode.anchor!
645-
while (cur && cur !== end) {
646-
const next = hostNextSibling(cur)
647-
hostInsert(cur, container, anchor)
648-
cur = next
640+
let next
641+
while (el && el !== anchor) {
642+
next = hostNextSibling(el)
643+
hostInsert(el, container, nextSibling)
644+
el = next
649645
}
650-
hostInsert(end, container, anchor)
646+
hostInsert(anchor!, container, nextSibling)
651647
}
652648

653-
const removeStaticNode = (vnode: VNode) => {
654-
let cur = vnode.el
655-
while (cur && cur !== vnode.anchor) {
656-
const next = hostNextSibling(cur)
657-
hostRemove(cur)
658-
cur = next
649+
const removeStaticNode = ({ el, anchor }: VNode) => {
650+
let next
651+
while (el && el !== anchor) {
652+
next = hostNextSibling(el)
653+
hostRemove(el)
654+
el = next
659655
}
660-
hostRemove(vnode.anchor!)
656+
hostRemove(anchor!)
661657
}
662658

663659
const processElement = (
@@ -1934,8 +1930,7 @@ function baseCreateRenderer(
19341930
return
19351931
}
19361932

1937-
// static node move can only happen when force updating HMR
1938-
if (__DEV__ && type === Static) {
1933+
if (type === Static) {
19391934
moveStaticNode(vnode, container, anchor)
19401935
return
19411936
}

0 commit comments

Comments
 (0)