]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: handle vapor teleport
authordaiwei <daiwei521@126.com>
Mon, 24 Mar 2025 06:27:46 +0000 (14:27 +0800)
committerdaiwei <daiwei521@126.com>
Mon, 24 Mar 2025 06:27:46 +0000 (14:27 +0800)
packages/compiler-vapor/src/generators/component.ts
packages/compiler-vapor/src/transforms/transformElement.ts
packages/compiler-vapor/src/utils.ts

index 7c232db754be5c6574fd04b8098eeff1e2cb368f..7dbf8c9a2f1564f110101feec3d5365a4727a1b8 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 '../utils'
 
 export function genCreateComponent(
   operation: CreateComponentIRNode,
@@ -92,8 +93,15 @@ 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 }),
+        extend(createSimpleExpression(tag, false), { ast: null }),
         context,
       )
     }
index dceb3fd6121f33da80dfd7121ede5ddbb9ad05bf..07f88ae0c584241f1dea99c8954b586210af2645 100644 (file)
@@ -36,7 +36,7 @@ import {
   type VaporDirectiveNode,
 } from '../ir'
 import { EMPTY_EXPRESSION } from './utils'
-import { findProp } from '../utils'
+import { findProp, isBuiltInComponent } from '../utils'
 
 export const isReservedProp: (key: string) => boolean = /*#__PURE__*/ makeMap(
   // the leading comma is intentional so empty string "" is also included
@@ -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)
index 728281914fd786f67aee7e73d6e4edd38c0ef2b7..9b99ef869cf3d1b97e448a846675410e30ef751c 100644 (file)
@@ -88,3 +88,14 @@ export function getLiteralExpressionValue(
   }
   return exp.isStatic ? exp.content : null
 }
+
+export function isTeleportTag(tag: string): boolean {
+  tag = tag.toLowerCase()
+  return tag === 'teleport' || tag === 'vaporteleport'
+}
+
+export function isBuiltInComponent(tag: string): string | undefined {
+  if (isTeleportTag(tag)) {
+    return 'VaporTeleport'
+  }
+}