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) {
155
155
*/
156
156
157
157
function getDefault ( options ) {
158
- // absent boolean value
159
- if ( options . type === Boolean ) {
160
- return false
161
- }
162
158
// no default, return undefined
163
159
if ( ! options . hasOwnProperty ( 'default' ) ) {
164
- return
160
+ // absent boolean value defaults to false
161
+ return options . type === Boolean
162
+ ? false
163
+ : undefined
165
164
}
166
165
var def = options . default
167
166
// warn against non-factory defaults for Object & Array
Original file line number Diff line number Diff line change @@ -447,6 +447,25 @@ if (_.inBrowser) {
447
447
} ) )
448
448
} )
449
449
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
+
450
469
it ( 'should initialize with default value when not provided & has default data' , function ( done ) {
451
470
var vm = new Vue ( {
452
471
el : el ,
You can’t perform that action at this time.
0 commit comments