Skip to content

Commit 7e593c2

Browse files
committed
wip: handle built-in components
1 parent 3a31f08 commit 7e593c2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/compiler-vapor/src/generators/component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { genEventHandler } from './event'
3939
import { genDirectiveModifiers, genDirectivesForElement } from './directive'
4040
import { genBlock } from './block'
4141
import { genModelHandler } from './vModel'
42+
import { isBuiltInComponent } from '../transforms/transformElement'
4243

4344
export function genCreateComponent(
4445
operation: CreateComponentIRNode,
@@ -90,6 +91,13 @@ export function genCreateComponent(
9091
} else if (operation.asset) {
9192
return toValidAssetId(operation.tag, 'component')
9293
} else {
94+
const { tag } = operation
95+
const builtInTag = isBuiltInComponent(tag)
96+
if (builtInTag) {
97+
// @ts-expect-error
98+
helper(builtInTag)
99+
return `_${builtInTag}`
100+
}
93101
return genExpression(
94102
extend(createSimpleExpression(operation.tag, false), { ast: null }),
95103
context,

packages/compiler-vapor/src/transforms/transformElement.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ function transformComponentElement(
109109
asset = false
110110
}
111111

112+
const builtInTag = isBuiltInComponent(tag)
113+
if (builtInTag) {
114+
tag = builtInTag
115+
asset = false
116+
}
117+
112118
const dotIndex = tag.indexOf('.')
113119
if (dotIndex > 0) {
114120
const ns = resolveSetupReference(tag.slice(0, dotIndex), context)
@@ -435,3 +441,9 @@ function mergePropValues(existing: IRProp, incoming: IRProp) {
435441
function isComponentTag(tag: string) {
436442
return tag === 'component' || tag === 'Component'
437443
}
444+
445+
export function isBuiltInComponent(tag: string): string | undefined {
446+
if (tag === 'Transition' || tag === 'transition') {
447+
return 'Transition'
448+
}
449+
}

0 commit comments

Comments
 (0)