File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed
Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,21 @@ describe('compiler: transform v-bind', () => {
133133 }
134134 } )
135135
136+ test ( 'no expression (false shorthand)' , ( ) => {
137+ const node = parseWithVBind ( `<div !id />` )
138+ const props = ( node . codegenNode as VNodeCall ) . props as ObjectExpression
139+ expect ( props . properties [ 0 ] ) . toMatchObject ( {
140+ key : {
141+ content : `id` ,
142+ isStatic : true ,
143+ } ,
144+ value : {
145+ content : `false` ,
146+ isStatic : false ,
147+ } ,
148+ } )
149+ } )
150+
136151 test ( 'dynamic arg' , ( ) => {
137152 const node = parseWithVBind ( `<div v-bind:[id]="id"/>` )
138153 const props = ( node . codegenNode as VNodeCall ) . props as CallExpression
Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ const tokenizer = new Tokenizer(stack, {
200200 ondirname ( start , end ) {
201201 const raw = getSlice ( start , end )
202202 const name =
203- raw === '.' || raw === ':'
203+ raw === '!' || raw === ' .' || raw === ':'
204204 ? 'bind'
205205 : raw === '@'
206206 ? 'on'
@@ -225,7 +225,7 @@ const tokenizer = new Tokenizer(stack, {
225225 type : NodeTypes . DIRECTIVE ,
226226 name,
227227 rawName : raw ,
228- exp : undefined ,
228+ exp : raw === '!' ? createSimpleExpression ( 'false' ) : undefined ,
229229 arg : undefined ,
230230 modifiers : raw === '.' ? [ createSimpleExpression ( 'prop' ) ] : [ ] ,
231231 loc : getLoc ( start ) ,
Original file line number Diff line number Diff line change @@ -665,6 +665,7 @@ export default class Tokenizer {
665665 this . state = State . InDirName
666666 this . sectionStart = this . index
667667 } else if (
668+ c === CharCodes . ExclamationMark ||
668669 c === CharCodes . Dot ||
669670 c === CharCodes . Colon ||
670671 c === CharCodes . At ||
You can’t perform that action at this time.
0 commit comments