feat(compiler): support keep-alive in templates
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { NO } from '@vue/shared'
|
||||
import { NO, makeMap } from '@vue/shared'
|
||||
import {
|
||||
ErrorCodes,
|
||||
createCompilerError,
|
||||
@@ -29,6 +29,12 @@ import {
|
||||
} from './ast'
|
||||
import { extend } from '@vue/shared'
|
||||
|
||||
// Portal and Fragment are native types, not components
|
||||
const isBuiltInComponent = /*#__PURE__*/ makeMap(
|
||||
`suspense,keep-alive,keepalive,transition`,
|
||||
true
|
||||
)
|
||||
|
||||
export interface ParserOptions {
|
||||
isVoidTag?: (tag: string) => boolean // e.g. img, br, hr
|
||||
isNativeTag?: (tag: string) => boolean // e.g. loading-indicator in weex
|
||||
@@ -467,15 +473,15 @@ function parseTag(
|
||||
if (!context.inPre && !context.options.isCustomElement(tag)) {
|
||||
if (context.options.isNativeTag) {
|
||||
if (!context.options.isNativeTag(tag)) tagType = ElementTypes.COMPONENT
|
||||
} else {
|
||||
if (/^[A-Z]/.test(tag)) tagType = ElementTypes.COMPONENT
|
||||
} else if (isBuiltInComponent(tag) || /^[A-Z]/.test(tag)) {
|
||||
tagType = ElementTypes.COMPONENT
|
||||
}
|
||||
|
||||
if (tag === 'slot') tagType = ElementTypes.SLOT
|
||||
else if (tag === 'template') tagType = ElementTypes.TEMPLATE
|
||||
else if (tag === 'portal' || tag === 'Portal') tagType = ElementTypes.PORTAL
|
||||
else if (tag === 'suspense' || tag === 'Suspense')
|
||||
tagType = ElementTypes.SUSPENSE
|
||||
if (tag === 'slot') {
|
||||
tagType = ElementTypes.SLOT
|
||||
} else if (tag === 'template') {
|
||||
tagType = ElementTypes.TEMPLATE
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user