Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/compiler-core/__tests__/transforms/vBind.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ describe('compiler: transform v-bind', () => {
}
})

test('no expression (false shorthand)', () => {
const node = parseWithVBind(`<div !id />`)
const props = (node.codegenNode as VNodeCall).props as ObjectExpression
expect(props.properties[0]).toMatchObject({
key: {
content: `id`,
isStatic: true,
},
value: {
content: `false`,
isStatic: false,
},
})
})

test('dynamic arg', () => {
const node = parseWithVBind(`<div v-bind:[id]="id"/>`)
const props = (node.codegenNode as VNodeCall).props as CallExpression
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-core/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const tokenizer = new Tokenizer(stack, {
ondirname(start, end) {
const raw = getSlice(start, end)
const name =
raw === '.' || raw === ':'
raw === '!' || raw === '.' || raw === ':'
? 'bind'
: raw === '@'
? 'on'
Expand All @@ -225,7 +225,7 @@ const tokenizer = new Tokenizer(stack, {
type: NodeTypes.DIRECTIVE,
name,
rawName: raw,
exp: undefined,
exp: raw === '!' ? createSimpleExpression('false') : undefined,
arg: undefined,
modifiers: raw === '.' ? [createSimpleExpression('prop')] : [],
loc: getLoc(start),
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-core/src/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ export default class Tokenizer {
this.state = State.InDirName
this.sectionStart = this.index
} else if (
c === CharCodes.ExclamationMark ||
c === CharCodes.Dot ||
c === CharCodes.Colon ||
c === CharCodes.At ||
Expand Down
Loading