mirror of https://github.com/vuejs/core.git
fix(runtime-core): disable tracking block in h function (#8213)
close #6913
This commit is contained in:
parent
e322436887
commit
8f6b505051
|
|
@ -7,6 +7,7 @@ import {
|
|||
type VNodeProps,
|
||||
createVNode,
|
||||
isVNode,
|
||||
setBlockTracking,
|
||||
} from './vnode'
|
||||
import type { Teleport, TeleportProps } from './components/Teleport'
|
||||
import type { Suspense, SuspenseProps } from './components/Suspense'
|
||||
|
|
@ -201,18 +202,28 @@ export function h<P>(
|
|||
|
||||
// Actual implementation
|
||||
export function h(type: any, propsOrChildren?: any, children?: any): VNode {
|
||||
// #6913 disable tracking block in h function
|
||||
const doCreateVNode = (type: any, props?: any, children?: any) => {
|
||||
setBlockTracking(-1)
|
||||
try {
|
||||
return createVNode(type, props, children)
|
||||
} finally {
|
||||
setBlockTracking(1)
|
||||
}
|
||||
}
|
||||
|
||||
const l = arguments.length
|
||||
if (l === 2) {
|
||||
if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
|
||||
// single vnode without props
|
||||
if (isVNode(propsOrChildren)) {
|
||||
return createVNode(type, null, [propsOrChildren])
|
||||
return doCreateVNode(type, null, [propsOrChildren])
|
||||
}
|
||||
// props without children
|
||||
return createVNode(type, propsOrChildren)
|
||||
return doCreateVNode(type, propsOrChildren)
|
||||
} else {
|
||||
// omit props
|
||||
return createVNode(type, null, propsOrChildren)
|
||||
return doCreateVNode(type, null, propsOrChildren)
|
||||
}
|
||||
} else {
|
||||
if (l > 3) {
|
||||
|
|
@ -220,6 +231,6 @@ export function h(type: any, propsOrChildren?: any, children?: any): VNode {
|
|||
} else if (l === 3 && isVNode(children)) {
|
||||
children = [children]
|
||||
}
|
||||
return createVNode(type, propsOrChildren, children)
|
||||
return doCreateVNode(type, propsOrChildren, children)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue