@@ -6,21 +6,26 @@ export default {
66 checked : undefined
77 }
88 } ,
9- mounted ( ) {
10- if ( this . value === undefined ) {
11- // if no value, we initialize to false, the the param will be correctly set
12- // i.e. myparam="false" or myparam="0" if uncheckvalue is defined
13- let defaultValue = this . config . default || "false"
14- let checkedvalue = this . config . checkedvalue || "true"
15- this . checked = `${ defaultValue } ` == `${ checkedvalue } `
16- }
17- else {
18- // Cast values to string before compare, because in yaml we might use boolean or number, but
19- // wikicode will always use strings
20- let checkedvalue = this . config . checkedvalue || "true"
21- this . checked = `${ this . value } ` == `${ checkedvalue } `
9+ methods : {
10+ setCheckedFromValue ( value ) {
11+ if ( value === undefined ) {
12+ // if no value, we initialize to false, the the param will be correctly set
13+ // i.e. myparam="false" or myparam="0" if uncheckvalue is defined
14+ let defaultValue = this . config . default || "false"
15+ let checkedvalue = this . config . checkedvalue || "true"
16+ this . checked = `${ defaultValue } ` == `${ checkedvalue } `
17+ }
18+ else {
19+ // Cast values to string before compare, because in yaml we might use boolean or number, but
20+ // wikicode will always use strings
21+ let checkedvalue = this . config . checkedvalue || "true"
22+ this . checked = `${ value } ` == `${ checkedvalue } `
23+ }
2224 }
2325 } ,
26+ mounted ( ) {
27+ this . setCheckedFromValue ( this . value ) ;
28+ } ,
2429 watch : {
2530 checked ( ) {
2631 let result
@@ -30,8 +35,7 @@ export default {
3035 } ,
3136 value ( ) {
3237 // watch value because it can be affected after mounted
33- let checkedvalue = this . config . checkedvalue || "true"
34- this . checked = `${ this . value } ` == `${ checkedvalue } `
38+ this . setCheckedFromValue ( this . value ) ;
3539 }
3640 } ,
3741 template : `
0 commit comments