]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: handle built-in components
authordaiwei <daiwei521@126.com>
Tue, 4 Mar 2025 07:12:02 +0000 (15:12 +0800)
committerdaiwei <daiwei521@126.com>
Tue, 4 Mar 2025 07:12:02 +0000 (15:12 +0800)
packages/compiler-vapor/src/generators/component.ts
packages/compiler-vapor/src/transforms/transformElement.ts

index b131ad2e9470a3f2e9390356589b555c76526957..8b0ab73e78ff97977d6014a60f88c843360b2b09 100644 (file)
@@ -39,6 +39,7 @@ import { genEventHandler } from './event'
 import { genDirectiveModifiers, genDirectivesForElement } from './directive'
 import { genBlock } from './block'
 import { genModelHandler } from './vModel'
+import { isBuiltInComponent } from '../transforms/transformElement'
 
 export function genCreateComponent(
   operation: CreateComponentIRNode,
@@ -90,6 +91,13 @@ export function genCreateComponent(
     } else if (operation.asset) {
       return toValidAssetId(operation.tag, 'component')
     } else {
+      const { tag } = operation
+      const builtInTag = isBuiltInComponent(tag)
+      if (builtInTag) {
+        // @ts-expect-error
+        helper(builtInTag)
+        return `_${builtInTag}`
+      }
       return genExpression(
         extend(createSimpleExpression(operation.tag, false), { ast: null }),
         context,
index f42801ace6d72f257aa02aa6663881d7229451c1..14cdf66c2ee78de960b8187d75d489b6bc5969a5 100644 (file)
@@ -109,6 +109,12 @@ function transformComponentElement(
       asset = false
     }
 
+    const builtInTag = isBuiltInComponent(tag)
+    if (builtInTag) {
+      tag = builtInTag
+      asset = false
+    }
+
     const dotIndex = tag.indexOf('.')
     if (dotIndex > 0) {
       const ns = resolveSetupReference(tag.slice(0, dotIndex), context)
@@ -435,3 +441,9 @@ function mergePropValues(existing: IRProp, incoming: IRProp) {
 function isComponentTag(tag: string) {
   return tag === 'component' || tag === 'Component'
 }
+
+export function isBuiltInComponent(tag: string): string | undefined {
+  if (tag === 'Transition' || tag === 'transition') {
+    return 'Transition'
+  }
+}