File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed
test/unit/specs/directives/internal Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -247,18 +247,23 @@ function guardComponents (options) {
247
247
248
248
function guardProps ( options ) {
249
249
var props = options . props
250
- var i
250
+ var i , val
251
251
if ( _ . isArray ( props ) ) {
252
252
options . props = { }
253
253
i = props . length
254
254
while ( i -- ) {
255
- options . props [ props [ i ] ] = null
255
+ val = props [ i ]
256
+ if ( typeof val === 'string' ) {
257
+ options . props [ val ] = null
258
+ } else if ( val . name ) {
259
+ options . props [ val . name ] = val
260
+ }
256
261
}
257
262
} else if ( _ . isPlainObject ( props ) ) {
258
263
var keys = Object . keys ( props )
259
264
i = keys . length
260
265
while ( i -- ) {
261
- var val = props [ keys [ i ] ]
266
+ val = props [ keys [ i ] ]
262
267
if ( typeof val === 'function' ) {
263
268
props [ keys [ i ] ] = { type : val }
264
269
}
Original file line number Diff line number Diff line change @@ -438,6 +438,36 @@ if (_.inBrowser) {
438
438
expect ( el . textContent ) . toBe ( 'AAA' )
439
439
} )
440
440
441
+ it ( 'mixed syntax' , function ( ) {
442
+ new Vue ( {
443
+ el : el ,
444
+ template : '<test :b="a" :c="d"></test>' ,
445
+ data : {
446
+ a : 'AAA' ,
447
+ d : 'DDD'
448
+ } ,
449
+ components : {
450
+ test : {
451
+ props : [
452
+ 'b' ,
453
+ {
454
+ name : 'c' ,
455
+ type : Number
456
+ } ,
457
+ {
458
+ name : 'd' ,
459
+ required : true
460
+ }
461
+ ] ,
462
+ template : '<p>{{b}}</p><p>{{c}}</p>'
463
+ }
464
+ }
465
+ } )
466
+ expect ( hasWarned ( _ , 'Missing required prop' ) ) . toBe ( true )
467
+ expect ( hasWarned ( _ , 'Expected Number' ) ) . toBe ( true )
468
+ expect ( el . textContent ) . toBe ( 'AAA' )
469
+ } )
470
+
441
471
it ( 'should not overwrite default value for an absent Boolean prop' , function ( ) {
442
472
var vm = new Vue ( {
443
473
el : el ,
You can’t perform that action at this time.
0 commit comments