Skip to content

Commit 1390ece

Browse files
committed
wip: refactor
1 parent 5052694 commit 1390ece

File tree

3 files changed

+24
-33
lines changed

3 files changed

+24
-33
lines changed

packages/compiler-core/src/parse.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -748,20 +748,27 @@ function parseAttribute(
748748
const modifiers = match[3] ? match[3].substr(1).split('.') : []
749749

750750
// 2.x compat v-bind:foo.sync -> v-model:foo
751-
if (
752-
__COMPAT__ &&
753-
dirName === 'bind' &&
754-
arg &&
755-
modifiers.includes('sync') &&
756-
checkCompatEnabled(
757-
CompilerDeprecationTypes.COMPILER_V_BIND_SYNC,
758-
context,
759-
loc,
760-
arg.loc.source
761-
)
762-
) {
763-
dirName = 'model'
764-
modifiers.splice(modifiers.indexOf('sync'), 1)
751+
if (__COMPAT__ && dirName === 'bind' && arg) {
752+
if (
753+
modifiers.includes('sync') &&
754+
checkCompatEnabled(
755+
CompilerDeprecationTypes.COMPILER_V_BIND_SYNC,
756+
context,
757+
loc,
758+
arg.loc.source
759+
)
760+
) {
761+
dirName = 'model'
762+
modifiers.splice(modifiers.indexOf('sync'), 1)
763+
}
764+
765+
if (__DEV__ && modifiers.includes('prop')) {
766+
checkCompatEnabled(
767+
CompilerDeprecationTypes.COMPILER_V_BIND_PROP,
768+
context,
769+
loc
770+
)
771+
}
765772
}
766773

767774
return {

packages/compiler-core/src/transforms/transformElement.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const transformElement: NodeTransform = (node, context) => {
9292
? resolveComponentType(node as ComponentNode, context)
9393
: `"${tag}"`
9494

95+
// 2.x <template> with no directives compat
9596
if (
9697
__COMPAT__ &&
9798
tag === 'template' &&
@@ -261,9 +262,7 @@ export function resolveComponentType(
261262
// if not <component>, only is value that starts with "vue:" will be
262263
// treated as component by the parse phase and reach here, unless it's
263264
// compat mode where all is values are considered components
264-
tag = __COMPAT__
265-
? isProp.value!.content.replace(/^vue:/, '')
266-
: isProp.value!.content.slice(4)
265+
tag = isProp.value!.content.replace(/^vue:/, '')
267266
} else {
268267
const exp =
269268
isProp.type === NodeTypes.ATTRIBUTE
@@ -509,6 +508,7 @@ export function buildProps(
509508
}
510509
if (isVBind) {
511510
if (__COMPAT__) {
511+
// 2.x v-bind object order compat
512512
if (__DEV__) {
513513
const hasOverridableKeys = mergeArgs.some(arg => {
514514
if (arg.type === NodeTypes.JS_OBJECT_EXPRESSION) {

packages/compiler-core/src/transforms/vBind.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import { createObjectProperty, createSimpleExpression, NodeTypes } from '../ast'
33
import { createCompilerError, ErrorCodes } from '../errors'
44
import { camelize } from '@vue/shared'
55
import { CAMELIZE } from '../runtimeHelpers'
6-
import {
7-
checkCompatEnabled,
8-
CompilerDeprecationTypes
9-
} from '../compat/compatConfig'
106

117
// v-bind without arg is handled directly in ./transformElements.ts due to it affecting
128
// codegen for the entire props object. This transform here is only for v-bind
@@ -37,18 +33,6 @@ export const transformBind: DirectiveTransform = (dir, _node, context) => {
3733
}
3834
}
3935

40-
if (__COMPAT__) {
41-
if (modifiers.includes('prop')) {
42-
checkCompatEnabled(
43-
CompilerDeprecationTypes.COMPILER_V_BIND_PROP,
44-
context,
45-
loc
46-
)
47-
}
48-
// .sync handling is performed directly in the parse phase to transform
49-
// it into v-model:arg equivalent.
50-
}
51-
5236
if (
5337
!exp ||
5438
(exp.type === NodeTypes.SIMPLE_EXPRESSION && !exp.content.trim())

0 commit comments

Comments
 (0)