mirror of https://github.com/vuejs/core.git
wip: handle vapor teleport
This commit is contained in:
parent
b232e456f4
commit
97e6174c41
|
@ -39,6 +39,7 @@ import { genEventHandler } from './event'
|
||||||
import { genDirectiveModifiers, genDirectivesForElement } from './directive'
|
import { genDirectiveModifiers, genDirectivesForElement } from './directive'
|
||||||
import { genBlock } from './block'
|
import { genBlock } from './block'
|
||||||
import { genModelHandler } from './vModel'
|
import { genModelHandler } from './vModel'
|
||||||
|
import { isBuiltInComponent } from '../utils'
|
||||||
|
|
||||||
export function genCreateComponent(
|
export function genCreateComponent(
|
||||||
operation: CreateComponentIRNode,
|
operation: CreateComponentIRNode,
|
||||||
|
@ -92,8 +93,15 @@ export function genCreateComponent(
|
||||||
} else if (operation.asset) {
|
} else if (operation.asset) {
|
||||||
return toValidAssetId(operation.tag, 'component')
|
return toValidAssetId(operation.tag, 'component')
|
||||||
} else {
|
} else {
|
||||||
|
const { tag } = operation
|
||||||
|
const builtInTag = isBuiltInComponent(tag)
|
||||||
|
if (builtInTag) {
|
||||||
|
// @ts-expect-error
|
||||||
|
helper(builtInTag)
|
||||||
|
return `_${builtInTag}`
|
||||||
|
}
|
||||||
return genExpression(
|
return genExpression(
|
||||||
extend(createSimpleExpression(operation.tag, false), { ast: null }),
|
extend(createSimpleExpression(tag, false), { ast: null }),
|
||||||
context,
|
context,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import {
|
||||||
type VaporDirectiveNode,
|
type VaporDirectiveNode,
|
||||||
} from '../ir'
|
} from '../ir'
|
||||||
import { EMPTY_EXPRESSION } from './utils'
|
import { EMPTY_EXPRESSION } from './utils'
|
||||||
import { findProp } from '../utils'
|
import { findProp, isBuiltInComponent } from '../utils'
|
||||||
|
|
||||||
export const isReservedProp: (key: string) => boolean = /*#__PURE__*/ makeMap(
|
export const isReservedProp: (key: string) => boolean = /*#__PURE__*/ makeMap(
|
||||||
// the leading comma is intentional so empty string "" is also included
|
// the leading comma is intentional so empty string "" is also included
|
||||||
|
@ -109,6 +109,12 @@ function transformComponentElement(
|
||||||
asset = false
|
asset = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const builtInTag = isBuiltInComponent(tag)
|
||||||
|
if (builtInTag) {
|
||||||
|
tag = builtInTag
|
||||||
|
asset = false
|
||||||
|
}
|
||||||
|
|
||||||
const dotIndex = tag.indexOf('.')
|
const dotIndex = tag.indexOf('.')
|
||||||
if (dotIndex > 0) {
|
if (dotIndex > 0) {
|
||||||
const ns = resolveSetupReference(tag.slice(0, dotIndex), context)
|
const ns = resolveSetupReference(tag.slice(0, dotIndex), context)
|
||||||
|
|
|
@ -88,3 +88,14 @@ export function getLiteralExpressionValue(
|
||||||
}
|
}
|
||||||
return exp.isStatic ? exp.content : null
|
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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue