mirror of https://github.com/vuejs/core.git
refactor: fix v-bind no-exp shorthand for new parser
This commit is contained in:
parent
e5afca6c1e
commit
94c86269d0
|
@ -80,32 +80,16 @@ describe('compiler: transform v-bind', () => {
|
|||
content: `id`,
|
||||
isStatic: true,
|
||||
loc: {
|
||||
start: {
|
||||
line: 1,
|
||||
column: 13,
|
||||
offset: 12
|
||||
},
|
||||
end: {
|
||||
line: 1,
|
||||
column: 15,
|
||||
offset: 14
|
||||
}
|
||||
start: { line: 1, column: 13, offset: 12 },
|
||||
end: { line: 1, column: 15, offset: 14 }
|
||||
}
|
||||
},
|
||||
value: {
|
||||
content: `id`,
|
||||
isStatic: false,
|
||||
loc: {
|
||||
start: {
|
||||
line: 1,
|
||||
column: 1,
|
||||
offset: 0
|
||||
},
|
||||
end: {
|
||||
line: 1,
|
||||
column: 1,
|
||||
offset: 0
|
||||
}
|
||||
start: { line: 1, column: 13, offset: 12 },
|
||||
end: { line: 1, column: 15, offset: 14 }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -3,7 +3,6 @@ import {
|
|||
createObjectProperty,
|
||||
createSimpleExpression,
|
||||
ExpressionNode,
|
||||
locStub,
|
||||
NodeTypes
|
||||
} from '../ast'
|
||||
import { createCompilerError, ErrorCodes } from '../errors'
|
||||
|
@ -18,6 +17,16 @@ export const transformBind: DirectiveTransform = (dir, _node, context) => {
|
|||
const { modifiers, loc } = dir
|
||||
const arg = dir.arg!
|
||||
|
||||
// :arg is replaced by :arg="arg"
|
||||
let { exp } = dir
|
||||
if (!exp && arg.type === NodeTypes.SIMPLE_EXPRESSION) {
|
||||
const propName = camelize(arg.content)
|
||||
exp = dir.exp = createSimpleExpression(propName, false, arg.loc)
|
||||
if (!__BROWSER__) {
|
||||
exp = dir.exp = processExpression(exp, context)
|
||||
}
|
||||
}
|
||||
|
||||
if (arg.type !== NodeTypes.SIMPLE_EXPRESSION) {
|
||||
arg.children.unshift(`(`)
|
||||
arg.children.push(`) || ""`)
|
||||
|
@ -48,18 +57,6 @@ export const transformBind: DirectiveTransform = (dir, _node, context) => {
|
|||
}
|
||||
}
|
||||
|
||||
// :arg is replaced by :arg="arg"
|
||||
let { exp } = dir
|
||||
if (!exp && arg.type === NodeTypes.SIMPLE_EXPRESSION) {
|
||||
const propName = camelize(arg.loc.source)
|
||||
const simpleExpression = createSimpleExpression(propName, false, {
|
||||
...locStub,
|
||||
source: propName
|
||||
})
|
||||
|
||||
exp = dir.exp = processExpression(simpleExpression, context)
|
||||
}
|
||||
|
||||
if (
|
||||
!exp ||
|
||||
(exp.type === NodeTypes.SIMPLE_EXPRESSION && !exp.content.trim())
|
||||
|
|
Loading…
Reference in New Issue