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) {
247247
248248function guardProps ( options ) {
249249 var props = options . props
250- var i
250+ var i , val
251251 if ( _ . isArray ( props ) ) {
252252 options . props = { }
253253 i = props . length
254254 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+ }
256261 }
257262 } else if ( _ . isPlainObject ( props ) ) {
258263 var keys = Object . keys ( props )
259264 i = keys . length
260265 while ( i -- ) {
261- var val = props [ keys [ i ] ]
266+ val = props [ keys [ i ] ]
262267 if ( typeof val === 'function' ) {
263268 props [ keys [ i ] ] = { type : val }
264269 }
Original file line number Diff line number Diff line change @@ -438,6 +438,36 @@ if (_.inBrowser) {
438438 expect ( el . textContent ) . toBe ( 'AAA' )
439439 } )
440440
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+
441471 it ( 'should not overwrite default value for an absent Boolean prop' , function ( ) {
442472 var vm = new Vue ( {
443473 el : el ,
You can’t perform that action at this time.
0 commit comments