File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -155,13 +155,12 @@ function makePropsLinkFn (props) {
155155 */
156156
157157function getDefault ( options ) {
158- // absent boolean value
159- if ( options . type === Boolean ) {
160- return false
161- }
162158 // no default, return undefined
163159 if ( ! options . hasOwnProperty ( 'default' ) ) {
164- return
160+ // absent boolean value defaults to false
161+ return options . type === Boolean
162+ ? false
163+ : undefined
165164 }
166165 var def = options . default
167166 // warn against non-factory defaults for Object & Array
Original file line number Diff line number Diff line change @@ -447,6 +447,25 @@ if (_.inBrowser) {
447447 } ) )
448448 } )
449449
450+ it ( 'should respect default value of a Boolean prop' , function ( ) {
451+ var vm = new Vue ( {
452+ el : el ,
453+ template : '<test></test>' ,
454+ components : {
455+ test : {
456+ props : {
457+ prop : {
458+ type : Boolean ,
459+ default : true
460+ }
461+ } ,
462+ template : '{{prop}}'
463+ }
464+ }
465+ } )
466+ expect ( vm . $el . textContent ) . toBe ( 'true' )
467+ } )
468+
450469 it ( 'should initialize with default value when not provided & has default data' , function ( done ) {
451470 var vm = new Vue ( {
452471 el : el ,
You can’t perform that action at this time.
0 commit comments