|
1 | | -import type { DirectiveTransform, TransformContext } from '../transform' |
| 1 | +import type { DirectiveTransform } from '../transform' |
2 | 2 | import { |
3 | | - type DirectiveNode, |
4 | 3 | type ExpressionNode, |
5 | 4 | NodeTypes, |
6 | | - type SimpleExpressionNode, |
7 | 5 | createObjectProperty, |
8 | 6 | createSimpleExpression, |
9 | 7 | } from '../ast' |
10 | 8 | import { ErrorCodes, createCompilerError } from '../errors' |
11 | 9 | import { camelize } from '@vue/shared' |
12 | 10 | import { CAMELIZE } from '../runtimeHelpers' |
13 | | -import { processExpression } from './transformExpression' |
14 | 11 |
|
15 | 12 | // v-bind without arg is handled directly in ./transformElement.ts due to its affecting |
16 | 13 | // codegen for the entire props object. This transform here is only for v-bind |
@@ -40,27 +37,6 @@ export const transformBind: DirectiveTransform = (dir, _node, context) => { |
40 | 37 | } |
41 | 38 | } |
42 | 39 |
|
43 | | - // same-name shorthand - :arg is expanded to :arg="arg" |
44 | | - if (!exp) { |
45 | | - if (arg.type !== NodeTypes.SIMPLE_EXPRESSION || !arg.isStatic) { |
46 | | - // only simple expression is allowed for same-name shorthand |
47 | | - context.onError( |
48 | | - createCompilerError( |
49 | | - ErrorCodes.X_V_BIND_INVALID_SAME_NAME_ARGUMENT, |
50 | | - arg.loc, |
51 | | - ), |
52 | | - ) |
53 | | - return { |
54 | | - props: [ |
55 | | - createObjectProperty(arg, createSimpleExpression('', true, loc)), |
56 | | - ], |
57 | | - } |
58 | | - } |
59 | | - |
60 | | - transformBindShorthand(dir, context) |
61 | | - exp = dir.exp! |
62 | | - } |
63 | | - |
64 | 40 | if (arg.type !== NodeTypes.SIMPLE_EXPRESSION) { |
65 | 41 | arg.children.unshift(`(`) |
66 | 42 | arg.children.push(`) || ""`) |
@@ -92,20 +68,7 @@ export const transformBind: DirectiveTransform = (dir, _node, context) => { |
92 | 68 | } |
93 | 69 |
|
94 | 70 | return { |
95 | | - props: [createObjectProperty(arg, exp)], |
96 | | - } |
97 | | -} |
98 | | - |
99 | | -export const transformBindShorthand = ( |
100 | | - dir: DirectiveNode, |
101 | | - context: TransformContext, |
102 | | -): void => { |
103 | | - const arg = dir.arg! |
104 | | - |
105 | | - const propName = camelize((arg as SimpleExpressionNode).content) |
106 | | - dir.exp = createSimpleExpression(propName, false, arg.loc) |
107 | | - if (!__BROWSER__) { |
108 | | - dir.exp = processExpression(dir.exp, context) |
| 71 | + props: [createObjectProperty(arg, exp!)], |
109 | 72 | } |
110 | 73 | } |
111 | 74 |
|
|
0 commit comments