fix(runtime-core): handle static node move in production
This commit is contained in:
parent
2a9ba0c8e9
commit
bf16a57fc3
@ -632,32 +632,28 @@ function baseCreateRenderer(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dev / HMR only
|
||||
*/
|
||||
const moveStaticNode = (
|
||||
vnode: VNode,
|
||||
{ el, anchor }: VNode,
|
||||
container: RendererElement,
|
||||
anchor: RendererNode | null
|
||||
nextSibling: RendererNode | null
|
||||
) => {
|
||||
let cur = vnode.el
|
||||
const end = vnode.anchor!
|
||||
while (cur && cur !== end) {
|
||||
const next = hostNextSibling(cur)
|
||||
hostInsert(cur, container, anchor)
|
||||
cur = next
|
||||
let next
|
||||
while (el && el !== anchor) {
|
||||
next = hostNextSibling(el)
|
||||
hostInsert(el, container, nextSibling)
|
||||
el = next
|
||||
}
|
||||
hostInsert(end, container, anchor)
|
||||
hostInsert(anchor!, container, nextSibling)
|
||||
}
|
||||
|
||||
const removeStaticNode = (vnode: VNode) => {
|
||||
let cur = vnode.el
|
||||
while (cur && cur !== vnode.anchor) {
|
||||
const next = hostNextSibling(cur)
|
||||
hostRemove(cur)
|
||||
cur = next
|
||||
const removeStaticNode = ({ el, anchor }: VNode) => {
|
||||
let next
|
||||
while (el && el !== anchor) {
|
||||
next = hostNextSibling(el)
|
||||
hostRemove(el)
|
||||
el = next
|
||||
}
|
||||
hostRemove(vnode.anchor!)
|
||||
hostRemove(anchor!)
|
||||
}
|
||||
|
||||
const processElement = (
|
||||
@ -1934,8 +1930,7 @@ function baseCreateRenderer(
|
||||
return
|
||||
}
|
||||
|
||||
// static node move can only happen when force updating HMR
|
||||
if (__DEV__ && type === Static) {
|
||||
if (type === Static) {
|
||||
moveStaticNode(vnode, container, anchor)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user