mirror of https://github.com/vuejs/core.git
fix(runtime-core): remove prod-only hoisted clone behavior for manual DOM manipulation compat
fix #6727 fix #6739
This commit is contained in:
parent
c0d8db81a6
commit
aa70188c41
|
@ -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,82 +617,71 @@ 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__ &&
|
el = vnode.el = hostCreateElement(
|
||||||
vnode.el &&
|
vnode.type as string,
|
||||||
hostCloneNode !== undefined &&
|
isSVG,
|
||||||
patchFlag === PatchFlags.HOISTED
|
props && props.is,
|
||||||
) {
|
props
|
||||||
// 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.
|
// mount children first, since some props may rely on child content
|
||||||
// only do this in production since cloned trees cannot be HMR updated.
|
// being already rendered, e.g. `<select value>`
|
||||||
el = vnode.el = hostCloneNode(vnode.el)
|
if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {
|
||||||
} else {
|
hostSetElementText(el, vnode.children as string)
|
||||||
el = vnode.el = hostCreateElement(
|
} else if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
|
||||||
vnode.type as string,
|
mountChildren(
|
||||||
isSVG,
|
vnode.children as VNodeArrayChildren,
|
||||||
props && props.is,
|
el,
|
||||||
props
|
null,
|
||||||
|
parentComponent,
|
||||||
|
parentSuspense,
|
||||||
|
isSVG && type !== 'foreignObject',
|
||||||
|
slotScopeIds,
|
||||||
|
optimized
|
||||||
)
|
)
|
||||||
|
|
||||||
// mount children first, since some props may rely on child content
|
|
||||||
// being already rendered, e.g. `<select value>`
|
|
||||||
if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {
|
|
||||||
hostSetElementText(el, vnode.children as string)
|
|
||||||
} else if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
|
|
||||||
mountChildren(
|
|
||||||
vnode.children as VNodeArrayChildren,
|
|
||||||
el,
|
|
||||||
null,
|
|
||||||
parentComponent,
|
|
||||||
parentSuspense,
|
|
||||||
isSVG && type !== 'foreignObject',
|
|
||||||
slotScopeIds,
|
|
||||||
optimized
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dirs) {
|
|
||||||
invokeDirectiveHook(vnode, null, parentComponent, 'created')
|
|
||||||
}
|
|
||||||
// props
|
|
||||||
if (props) {
|
|
||||||
for (const key in props) {
|
|
||||||
if (key !== 'value' && !isReservedProp(key)) {
|
|
||||||
hostPatchProp(
|
|
||||||
el,
|
|
||||||
key,
|
|
||||||
null,
|
|
||||||
props[key],
|
|
||||||
isSVG,
|
|
||||||
vnode.children as VNode[],
|
|
||||||
parentComponent,
|
|
||||||
parentSuspense,
|
|
||||||
unmountChildren
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Special case for setting value on DOM elements:
|
|
||||||
* - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
|
|
||||||
* - it needs to be forced (#1471)
|
|
||||||
* #2353 proposes adding another renderer option to configure this, but
|
|
||||||
* the properties affects are so finite it is worth special casing it
|
|
||||||
* here to reduce the complexity. (Special casing it also should not
|
|
||||||
* affect non-DOM renderers)
|
|
||||||
*/
|
|
||||||
if ('value' in props) {
|
|
||||||
hostPatchProp(el, 'value', null, props.value)
|
|
||||||
}
|
|
||||||
if ((vnodeHook = props.onVnodeBeforeMount)) {
|
|
||||||
invokeVNodeHook(vnodeHook, parentComponent, vnode)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// scopeId
|
|
||||||
setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dirs) {
|
||||||
|
invokeDirectiveHook(vnode, null, parentComponent, 'created')
|
||||||
|
}
|
||||||
|
// props
|
||||||
|
if (props) {
|
||||||
|
for (const key in props) {
|
||||||
|
if (key !== 'value' && !isReservedProp(key)) {
|
||||||
|
hostPatchProp(
|
||||||
|
el,
|
||||||
|
key,
|
||||||
|
null,
|
||||||
|
props[key],
|
||||||
|
isSVG,
|
||||||
|
vnode.children as VNode[],
|
||||||
|
parentComponent,
|
||||||
|
parentSuspense,
|
||||||
|
unmountChildren
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Special case for setting value on DOM elements:
|
||||||
|
* - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
|
||||||
|
* - it needs to be forced (#1471)
|
||||||
|
* #2353 proposes adding another renderer option to configure this, but
|
||||||
|
* the properties affects are so finite it is worth special casing it
|
||||||
|
* here to reduce the complexity. (Special casing it also should not
|
||||||
|
* affect non-DOM renderers)
|
||||||
|
*/
|
||||||
|
if ('value' in props) {
|
||||||
|
hostPatchProp(el, 'value', null, props.value)
|
||||||
|
}
|
||||||
|
if ((vnodeHook = props.onVnodeBeforeMount)) {
|
||||||
|
invokeVNodeHook(vnodeHook, parentComponent, vnode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// scopeId
|
||||||
|
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,
|
||||||
|
|
Loading…
Reference in New Issue