wip: inline-template compat
This commit is contained in:
parent
1390ece04f
commit
3ea68691e2
@ -20,7 +20,9 @@ export const enum CompilerDeprecationTypes {
|
|||||||
COMPILER_V_BIND_OBJECT_ORDER = 'COMPILER_V_BIND_OBJECT_ORDER',
|
COMPILER_V_BIND_OBJECT_ORDER = 'COMPILER_V_BIND_OBJECT_ORDER',
|
||||||
COMPILER_V_ON_NATIVE = 'COMPILER_V_ON_NATIVE',
|
COMPILER_V_ON_NATIVE = 'COMPILER_V_ON_NATIVE',
|
||||||
COMPILER_V_IF_V_FOR_PRECEDENCE = 'COMPILER_V_IF_V_FOR_PRECEDENCE',
|
COMPILER_V_IF_V_FOR_PRECEDENCE = 'COMPILER_V_IF_V_FOR_PRECEDENCE',
|
||||||
COMPILER_NATIVE_TEMPLATE = 'COMPILER_NATIVE_TEMPLATE'
|
COMPILER_NATIVE_TEMPLATE = 'COMPILER_NATIVE_TEMPLATE',
|
||||||
|
COMPILER_INLINE_TEMPLATE = 'COMPILER_INLINE_TEMPLATE',
|
||||||
|
COMPILER_FILTER = 'COMPILER_FILTER'
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeprecationData = {
|
type DeprecationData = {
|
||||||
@ -80,6 +82,16 @@ const deprecationData: Record<CompilerDeprecationTypes, DeprecationData> = {
|
|||||||
message:
|
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.`
|
`element instead of its inner content in Vue 3.`
|
||||||
|
},
|
||||||
|
|
||||||
|
[CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE]: {
|
||||||
|
message: `"inline-template" has been removed in Vue 3.`,
|
||||||
|
link: `https://v3.vuejs.org/guide/migration/inline-template-attribute.html`
|
||||||
|
},
|
||||||
|
|
||||||
|
[CompilerDeprecationTypes.COMPILER_FILTER]: {
|
||||||
|
message: `filters have been removed in Vue 3.`,
|
||||||
|
link: `https://v3.vuejs.org/guide/migration/filters.html`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,6 +406,27 @@ function parseElement(
|
|||||||
const children = parseChildren(context, mode, ancestors)
|
const children = parseChildren(context, mode, ancestors)
|
||||||
ancestors.pop()
|
ancestors.pop()
|
||||||
|
|
||||||
|
// 2.x inline-template compat
|
||||||
|
if (__COMPAT__) {
|
||||||
|
const inlineTemplateProp = element.props.find(
|
||||||
|
p => p.type === NodeTypes.ATTRIBUTE && p.name === 'inline-template'
|
||||||
|
) as AttributeNode
|
||||||
|
if (
|
||||||
|
inlineTemplateProp &&
|
||||||
|
checkCompatEnabled(
|
||||||
|
CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE,
|
||||||
|
context,
|
||||||
|
inlineTemplateProp.loc
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
inlineTemplateProp.value!.content = getSelection(
|
||||||
|
context,
|
||||||
|
element.loc.end
|
||||||
|
).source
|
||||||
|
console.log(inlineTemplateProp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
element.children = children
|
element.children = children
|
||||||
|
|
||||||
// End tag.
|
// End tag.
|
||||||
@ -516,7 +537,7 @@ function parseTag(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// warn v-if/v-for usage on the same element
|
// 2.x deprecation checks
|
||||||
if (__COMPAT__ && __DEV__ && !__TEST__) {
|
if (__COMPAT__ && __DEV__ && !__TEST__) {
|
||||||
let hasIf = false
|
let hasIf = false
|
||||||
let hasFor = false
|
let hasFor = false
|
||||||
|
@ -712,7 +712,13 @@ export function finishComponentSetup(
|
|||||||
NOOP) as InternalRenderFunction
|
NOOP) as InternalRenderFunction
|
||||||
} else if (!instance.render) {
|
} else if (!instance.render) {
|
||||||
// could be set from setup()
|
// could be set from setup()
|
||||||
if (compile && Component.template && !Component.render) {
|
if (compile && !Component.render) {
|
||||||
|
const template =
|
||||||
|
(__COMPAT__ &&
|
||||||
|
instance.vnode.props &&
|
||||||
|
instance.vnode.props['inline-template']) ||
|
||||||
|
Component.template
|
||||||
|
if (template) {
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
startMeasure(instance, `compile`)
|
startMeasure(instance, `compile`)
|
||||||
}
|
}
|
||||||
@ -727,11 +733,12 @@ export function finishComponentSetup(
|
|||||||
extend(compilerOptions.compatConfig, Component.compatConfig)
|
extend(compilerOptions.compatConfig, Component.compatConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component.render = compile(Component.template, compilerOptions)
|
Component.render = compile(template, compilerOptions)
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
endMeasure(instance, `compile`)
|
endMeasure(instance, `compile`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
instance.render = (Component.render || NOOP) as InternalRenderFunction
|
instance.render = (Component.render || NOOP) as InternalRenderFunction
|
||||||
|
|
||||||
|
@ -297,13 +297,18 @@ function setFullProps(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__COMPAT__ && key.startsWith('onHook:')) {
|
if (__COMPAT__) {
|
||||||
|
if (key.startsWith('onHook:')) {
|
||||||
softAssertCompatEnabled(
|
softAssertCompatEnabled(
|
||||||
DeprecationTypes.INSTANCE_EVENT_HOOKS,
|
DeprecationTypes.INSTANCE_EVENT_HOOKS,
|
||||||
instance,
|
instance,
|
||||||
key.slice(2).toLowerCase()
|
key.slice(2).toLowerCase()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (key === 'inline-template') {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const value = rawProps[key]
|
const value = rawProps[key]
|
||||||
// prop option names are camelized during normalization, so to support
|
// prop option names are camelized during normalization, so to support
|
||||||
|
Loading…
Reference in New Issue
Block a user