Skip to content

Commit 8f6b505

Browse files
authored
fix(runtime-core): disable tracking block in h function (#8213)
close #6913
1 parent e322436 commit 8f6b505

File tree

1 file changed

+15
-4
lines changed
  • packages/runtime-core/src

1 file changed

+15
-4
lines changed

packages/runtime-core/src/h.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
type VNodeProps,
88
createVNode,
99
isVNode,
10+
setBlockTracking,
1011
} from './vnode'
1112
import type { Teleport, TeleportProps } from './components/Teleport'
1213
import type { Suspense, SuspenseProps } from './components/Suspense'
@@ -201,25 +202,35 @@ export function h<P>(
201202

202203
// Actual implementation
203204
export function h(type: any, propsOrChildren?: any, children?: any): VNode {
205+
// #6913 disable tracking block in h function
206+
const doCreateVNode = (type: any, props?: any, children?: any) => {
207+
setBlockTracking(-1)
208+
try {
209+
return createVNode(type, props, children)
210+
} finally {
211+
setBlockTracking(1)
212+
}
213+
}
214+
204215
const l = arguments.length
205216
if (l === 2) {
206217
if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
207218
// single vnode without props
208219
if (isVNode(propsOrChildren)) {
209-
return createVNode(type, null, [propsOrChildren])
220+
return doCreateVNode(type, null, [propsOrChildren])
210221
}
211222
// props without children
212-
return createVNode(type, propsOrChildren)
223+
return doCreateVNode(type, propsOrChildren)
213224
} else {
214225
// omit props
215-
return createVNode(type, null, propsOrChildren)
226+
return doCreateVNode(type, null, propsOrChildren)
216227
}
217228
} else {
218229
if (l > 3) {
219230
children = Array.prototype.slice.call(arguments, 2)
220231
} else if (l === 3 && isVNode(children)) {
221232
children = [children]
222233
}
223-
return createVNode(type, propsOrChildren, children)
234+
return doCreateVNode(type, propsOrChildren, children)
224235
}
225236
}

0 commit comments

Comments
 (0)