wip: plain template tag compat
This commit is contained in:
parent
048ac299f3
commit
505269405e
@ -78,7 +78,7 @@ const deprecationData: Record<CompilerDeprecationTypes, DeprecationData> = {
|
||||
|
||||
[CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE]: {
|
||||
message:
|
||||
`<template> with no special directives will render as a native template` +
|
||||
`<template> with no special directives will render as a native template ` +
|
||||
`element instead of its inner content in Vue 3.`
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,8 @@ import {
|
||||
TELEPORT,
|
||||
KEEP_ALIVE,
|
||||
SUSPENSE,
|
||||
UNREF
|
||||
UNREF,
|
||||
FRAGMENT
|
||||
} from '../runtimeHelpers'
|
||||
import {
|
||||
getInnerRange,
|
||||
@ -87,9 +88,22 @@ export const transformElement: NodeTransform = (node, context) => {
|
||||
|
||||
// The goal of the transform is to create a codegenNode implementing the
|
||||
// VNodeCall interface.
|
||||
const vnodeTag = isComponent
|
||||
let vnodeTag = isComponent
|
||||
? resolveComponentType(node as ComponentNode, context)
|
||||
: `"${tag}"`
|
||||
|
||||
if (
|
||||
__COMPAT__ &&
|
||||
tag === 'template' &&
|
||||
checkCompatEnabled(
|
||||
CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE,
|
||||
context,
|
||||
node.loc
|
||||
)
|
||||
) {
|
||||
vnodeTag = context.helper(FRAGMENT)
|
||||
}
|
||||
|
||||
const isDynamicComponent =
|
||||
isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT
|
||||
|
||||
|
@ -63,7 +63,11 @@ export const transformText: NodeTransform = (node, context) => {
|
||||
(children.length === 1 &&
|
||||
(node.type === NodeTypes.ROOT ||
|
||||
(node.type === NodeTypes.ELEMENT &&
|
||||
node.tagType === ElementTypes.ELEMENT)))
|
||||
node.tagType === ElementTypes.ELEMENT &&
|
||||
// in compat mode, <template> tags with no special directives
|
||||
// will be rendered as a fragment so its children must be
|
||||
// converted into vnodes.
|
||||
!(__COMPAT__ && node.tag === 'template'))))
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user