]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): simplify block-tracking disabling in h() (#13841) 13877/head
authoredison <daiwei521@126.com>
Wed, 3 Sep 2025 01:13:09 +0000 (09:13 +0800)
committerGitHub <noreply@github.com>
Wed, 3 Sep 2025 01:13:09 +0000 (09:13 +0800)
packages/runtime-core/src/h.ts

index ba4ebcb7f890099ca92057b28649dd29390f6b16..adc984563b2f3ce70f8823f3ce37fc7f1d2d5d1f 100644 (file)
@@ -202,35 +202,31 @@ 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) => {
+  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)
   }
 }