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 = (
|
const moveStaticNode = (
|
||||||
vnode: VNode,
|
{ el, anchor }: VNode,
|
||||||
container: RendererElement,
|
container: RendererElement,
|
||||||
anchor: RendererNode | null
|
nextSibling: RendererNode | null
|
||||||
) => {
|
) => {
|
||||||
let cur = vnode.el
|
let next
|
||||||
const end = vnode.anchor!
|
while (el && el !== anchor) {
|
||||||
while (cur && cur !== end) {
|
next = hostNextSibling(el)
|
||||||
const next = hostNextSibling(cur)
|
hostInsert(el, container, nextSibling)
|
||||||
hostInsert(cur, container, anchor)
|
el = next
|
||||||
cur = next
|
|
||||||
}
|
}
|
||||||
hostInsert(end, container, anchor)
|
hostInsert(anchor!, container, nextSibling)
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeStaticNode = (vnode: VNode) => {
|
const removeStaticNode = ({ el, anchor }: VNode) => {
|
||||||
let cur = vnode.el
|
let next
|
||||||
while (cur && cur !== vnode.anchor) {
|
while (el && el !== anchor) {
|
||||||
const next = hostNextSibling(cur)
|
next = hostNextSibling(el)
|
||||||
hostRemove(cur)
|
hostRemove(el)
|
||||||
cur = next
|
el = next
|
||||||
}
|
}
|
||||||
hostRemove(vnode.anchor!)
|
hostRemove(anchor!)
|
||||||
}
|
}
|
||||||
|
|
||||||
const processElement = (
|
const processElement = (
|
||||||
@ -1934,8 +1930,7 @@ function baseCreateRenderer(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// static node move can only happen when force updating HMR
|
if (type === Static) {
|
||||||
if (__DEV__ && type === Static) {
|
|
||||||
moveStaticNode(vnode, container, anchor)
|
moveStaticNode(vnode, container, anchor)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user