From: edison Date: Wed, 3 Sep 2025 01:13:09 +0000 (+0800) Subject: fix(runtime-core): simplify block-tracking disabling in h() (#13841) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F13877%2Fhead;p=thirdparty%2Fvuejs%2Fcore.git fix(runtime-core): simplify block-tracking disabling in h() (#13841) --- diff --git a/packages/runtime-core/src/h.ts b/packages/runtime-core/src/h.ts index ba4ebcb7f..adc984563 100644 --- a/packages/runtime-core/src/h.ts +++ b/packages/runtime-core/src/h.ts @@ -202,35 +202,31 @@ export function h

( // 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) => { + try { + // #6913 disable tracking block in h function 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 doCreateVNode(type, null, [propsOrChildren]) + const l = arguments.length + if (l === 2) { + if (isObject(propsOrChildren) && !isArray(propsOrChildren)) { + // single vnode without props + if (isVNode(propsOrChildren)) { + return createVNode(type, null, [propsOrChildren]) + } + // props without children + return createVNode(type, propsOrChildren) + } else { + // omit props + return createVNode(type, null, propsOrChildren) } - // props without children - return doCreateVNode(type, propsOrChildren) } else { - // omit props - return doCreateVNode(type, null, propsOrChildren) - } - } else { - if (l > 3) { - children = Array.prototype.slice.call(arguments, 2) - } else if (l === 3 && isVNode(children)) { - children = [children] + if (l > 3) { + children = Array.prototype.slice.call(arguments, 2) + } else if (l === 3 && isVNode(children)) { + children = [children] + } + return createVNode(type, propsOrChildren, children) } - return doCreateVNode(type, propsOrChildren, children) + } finally { + setBlockTracking(1) } }