File tree 2 files changed +79
-1
lines changed
test/unit/features/options
2 files changed +79
-1
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ const dynamicArgRE = /^\[.*\]$/
33
33
const argRE = / : ( .* ) $ /
34
34
export const bindRE = / ^ : | ^ \. | ^ v - b i n d : /
35
35
const propBindRE = / ^ \. /
36
- const modifierRE = / \. [ ^ . ] + / g
36
+ const modifierRE = / \. [ ^ . \] ] + (? = [ ^ \] ] * $ ) / g
37
37
38
38
const slotRE = / ^ v - s l o t ( : | $ ) | ^ # /
39
39
Original file line number Diff line number Diff line change @@ -287,4 +287,82 @@ describe('Options directives', () => {
287
287
} ) . $mount ( )
288
288
vm . key = 'bar'
289
289
} )
290
+
291
+ it ( 'deep object like `deep.a` as dynamic arguments' , done => {
292
+ const vm = new Vue ( {
293
+ template : `<div v-my:[deep.a]="1"/>` ,
294
+ data : {
295
+ deep : {
296
+ a : 'foo'
297
+ }
298
+ } ,
299
+ directives : {
300
+ my : {
301
+ bind ( el , binding ) {
302
+ expect ( binding . arg ) . toBe ( 'foo' )
303
+ } ,
304
+ update ( el , binding ) {
305
+ expect ( binding . arg ) . toBe ( 'bar' )
306
+ expect ( binding . oldArg ) . toBe ( 'foo' )
307
+ done ( )
308
+ }
309
+ }
310
+ }
311
+ } ) . $mount ( )
312
+ vm . deep . a = 'bar'
313
+ } )
314
+
315
+ it ( 'deep object like `deep.a.b` as dynamic arguments' , done => {
316
+ const vm = new Vue ( {
317
+ template : `<div v-my:[deep.a.b]="1"/>` ,
318
+ data : {
319
+ deep : {
320
+ a : {
321
+ b : 'foo'
322
+ }
323
+ }
324
+ } ,
325
+ directives : {
326
+ my : {
327
+ bind ( el , binding ) {
328
+ expect ( binding . arg ) . toBe ( 'foo' )
329
+ } ,
330
+ update ( el , binding ) {
331
+ expect ( binding . arg ) . toBe ( 'bar' )
332
+ expect ( binding . oldArg ) . toBe ( 'foo' )
333
+ done ( )
334
+ }
335
+ }
336
+ }
337
+ } ) . $mount ( )
338
+ vm . deep . a . b = 'bar'
339
+ } )
340
+
341
+ it ( 'deep object as dynamic arguments with modifiers' , done => {
342
+ const vm = new Vue ( {
343
+ template : `<div v-my:[deep.a.b].x.y="1"/>` ,
344
+ data : {
345
+ deep : {
346
+ a : {
347
+ b : 'foo'
348
+ }
349
+ }
350
+ } ,
351
+ directives : {
352
+ my : {
353
+ bind ( el , binding ) {
354
+ expect ( binding . arg ) . toBe ( 'foo' )
355
+ expect ( binding . modifiers . x ) . toBe ( true )
356
+ expect ( binding . modifiers . y ) . toBe ( true )
357
+ } ,
358
+ update ( el , binding ) {
359
+ expect ( binding . arg ) . toBe ( 'bar' )
360
+ expect ( binding . oldArg ) . toBe ( 'foo' )
361
+ done ( )
362
+ }
363
+ }
364
+ }
365
+ } ) . $mount ( )
366
+ vm . deep . a . b = 'bar'
367
+ } )
290
368
} )
You can’t perform that action at this time.
0 commit comments