fix(compiler-core): prevent generating invalid code for v-bind with empty expression (#1720)

This commit is contained in:
underfin
2020-07-28 06:31:08 +08:00
committed by GitHub
parent 5fbd1f4ccb
commit d4527230e4
2 changed files with 24 additions and 7 deletions

View File

@@ -83,7 +83,8 @@ describe('compiler: transform v-bind', () => {
test('should error if no expression', () => {
const onError = jest.fn()
parseWithVBind(`<div v-bind:arg />`, { onError })
const node = parseWithVBind(`<div v-bind:arg />`, { onError })
const props = (node.codegenNode as VNodeCall).props as ObjectExpression
expect(onError.mock.calls[0][0]).toMatchObject({
code: ErrorCodes.X_V_BIND_NO_EXPRESSION,
loc: {
@@ -97,6 +98,16 @@ describe('compiler: transform v-bind', () => {
}
}
})
expect(props.properties[0]).toMatchObject({
key: {
content: `arg`,
isStatic: true
},
value: {
content: ``,
isStatic: true
}
})
})
test('.camel modifier', () => {