wip: inline-template compat

This commit is contained in:
Evan You
2021-04-17 23:19:40 -04:00
parent 1390ece04f
commit 3ea68691e2
4 changed files with 70 additions and 25 deletions

View File

@@ -712,24 +712,31 @@ export function finishComponentSetup(
NOOP) as InternalRenderFunction
} else if (!instance.render) {
// could be set from setup()
if (compile && Component.template && !Component.render) {
if (__DEV__) {
startMeasure(instance, `compile`)
}
const compilerOptions: CompilerOptions = {
isCustomElement: instance.appContext.config.isCustomElement,
delimiters: Component.delimiters
}
if (__COMPAT__) {
// pass runtime compat config into the compiler
compilerOptions.compatConfig = Object.create(globalCompatConfig)
if (Component.compatConfig) {
extend(compilerOptions.compatConfig, Component.compatConfig)
if (compile && !Component.render) {
const template =
(__COMPAT__ &&
instance.vnode.props &&
instance.vnode.props['inline-template']) ||
Component.template
if (template) {
if (__DEV__) {
startMeasure(instance, `compile`)
}
const compilerOptions: CompilerOptions = {
isCustomElement: instance.appContext.config.isCustomElement,
delimiters: Component.delimiters
}
if (__COMPAT__) {
// pass runtime compat config into the compiler
compilerOptions.compatConfig = Object.create(globalCompatConfig)
if (Component.compatConfig) {
extend(compilerOptions.compatConfig, Component.compatConfig)
}
}
Component.render = compile(template, compilerOptions)
if (__DEV__) {
endMeasure(instance, `compile`)
}
}
Component.render = compile(Component.template, compilerOptions)
if (__DEV__) {
endMeasure(instance, `compile`)
}
}

View File

@@ -297,12 +297,17 @@ function setFullProps(
continue
}
if (__COMPAT__ && key.startsWith('onHook:')) {
softAssertCompatEnabled(
DeprecationTypes.INSTANCE_EVENT_HOOKS,
instance,
key.slice(2).toLowerCase()
)
if (__COMPAT__) {
if (key.startsWith('onHook:')) {
softAssertCompatEnabled(
DeprecationTypes.INSTANCE_EVENT_HOOKS,
instance,
key.slice(2).toLowerCase()
)
}
if (key === 'inline-template') {
continue
}
}
const value = rawProps[key]