wip: v-bind.sync compat

This commit is contained in:
Evan You
2021-04-16 17:11:44 -04:00
parent ad97bbab85
commit 7ceb873783
4 changed files with 48 additions and 7 deletions

View File

@@ -3,11 +3,15 @@ import { createObjectProperty, createSimpleExpression, NodeTypes } from '../ast'
import { createCompilerError, ErrorCodes } from '../errors'
import { camelize } from '@vue/shared'
import { CAMELIZE } from '../runtimeHelpers'
import {
checkCompatEnabled,
CompilerDeprecationTypes
} from '../compat/compatConfig'
// v-bind without arg is handled directly in ./transformElements.ts due to it affecting
// codegen for the entire props object. This transform here is only for v-bind
// *with* args.
export const transformBind: DirectiveTransform = (dir, node, context) => {
export const transformBind: DirectiveTransform = (dir, _node, context) => {
const { exp, modifiers, loc } = dir
const arg = dir.arg!
@@ -33,6 +37,18 @@ export const transformBind: DirectiveTransform = (dir, node, context) => {
}
}
if (__COMPAT__) {
if (modifiers.includes('prop')) {
checkCompatEnabled(
CompilerDeprecationTypes.COMPILER_V_BIND_PROP,
context,
loc
)
}
// .sync handling is performed directly in the parse phase to transform
// it into v-model:arg equivalent.
}
if (
!exp ||
(exp.type === NodeTypes.SIMPLE_EXPRESSION && !exp.content.trim())