fix(runtime-core): remove prod-only hoisted clone behavior for manual DOM manipulation compat

fix #6727
fix #6739
This commit is contained in:
Evan You 2022-09-27 15:24:46 +08:00
parent c0d8db81a6
commit aa70188c41
1 changed files with 63 additions and 75 deletions

View File

@ -345,7 +345,6 @@ function baseCreateRenderer(
parentNode: hostParentNode, parentNode: hostParentNode,
nextSibling: hostNextSibling, nextSibling: hostNextSibling,
setScopeId: hostSetScopeId = NOOP, setScopeId: hostSetScopeId = NOOP,
cloneNode: hostCloneNode,
insertStaticContent: hostInsertStaticContent insertStaticContent: hostInsertStaticContent
} = options } = options
@ -618,19 +617,8 @@ function baseCreateRenderer(
) => { ) => {
let el: RendererElement let el: RendererElement
let vnodeHook: VNodeHook | undefined | null let vnodeHook: VNodeHook | undefined | null
const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode const { type, props, shapeFlag, transition, dirs } = vnode
if (
!__DEV__ &&
vnode.el &&
hostCloneNode !== undefined &&
patchFlag === PatchFlags.HOISTED
) {
// If a vnode has non-null el, it means it's being reused.
// Only static vnodes can be reused, so its mounted DOM nodes should be
// exactly the same, and we can simply do a clone here.
// only do this in production since cloned trees cannot be HMR updated.
el = vnode.el = hostCloneNode(vnode.el)
} else {
el = vnode.el = hostCreateElement( el = vnode.el = hostCreateElement(
vnode.type as string, vnode.type as string,
isSVG, isSVG,
@ -693,7 +681,7 @@ function baseCreateRenderer(
} }
// scopeId // scopeId
setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent) setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent)
}
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
Object.defineProperty(el, '__vnode', { Object.defineProperty(el, '__vnode', {
value: vnode, value: vnode,