@@ -26,7 +26,7 @@ export default function model (
26
26
}
27
27
}
28
28
29
- function genCheckboxModel ( el : ASTElement , value : ? string ) {
29
+ function genCheckboxModel ( el : ASTElement , value : string ) {
30
30
if ( process . env . NODE_ENV !== 'production' &&
31
31
el . attrsMap . checked != null ) {
32
32
warn (
@@ -35,7 +35,7 @@ function genCheckboxModel (el: ASTElement, value: ?string) {
35
35
'Declare initial values in the component\'s data option instead.'
36
36
)
37
37
}
38
- const valueBinding = getBindingAttr ( el , 'value' )
38
+ const valueBinding = getBindingAttr ( el , 'value' ) || 'null'
39
39
const trueValueBinding = getBindingAttr ( el , 'true-value' ) || 'true'
40
40
const falseValueBinding = getBindingAttr ( el , 'false-value' ) || 'false'
41
41
addProp ( el , 'checked' ,
@@ -57,7 +57,7 @@ function genCheckboxModel (el: ASTElement, value: ?string) {
57
57
)
58
58
}
59
59
60
- function genRadioModel ( el : ASTElement , value : ? string ) {
60
+ function genRadioModel ( el : ASTElement , value : string ) {
61
61
if ( process . env . NODE_ENV !== 'production' &&
62
62
el . attrsMap . checked != null ) {
63
63
warn (
@@ -66,14 +66,14 @@ function genRadioModel (el: ASTElement, value: ?string) {
66
66
'Declare initial values in the component\'s data option instead.'
67
67
)
68
68
}
69
- const valueBinding = getBindingAttr ( el , 'value' )
69
+ const valueBinding = getBindingAttr ( el , 'value' ) || 'null'
70
70
addProp ( el , 'checked' , `(${ value } )===(${ valueBinding } )` )
71
71
addHandler ( el , 'change' , `${ value } =${ valueBinding } ` , null , true )
72
72
}
73
73
74
74
function genDefaultModel (
75
75
el : ASTElement ,
76
- value : ? string ,
76
+ value : string ,
77
77
modifiers : ?Object
78
78
) : ?boolean {
79
79
if ( process . env . NODE_ENV !== 'production' ) {
@@ -116,7 +116,7 @@ function genDefaultModel (
116
116
}
117
117
}
118
118
119
- function genSelect ( el : ASTElement , value : ? string ) {
119
+ function genSelect ( el : ASTElement , value : string ) {
120
120
if ( process . env . NODE_ENV !== 'production' ) {
121
121
el . children . some ( checkOptionWarning )
122
122
}
@@ -129,18 +129,16 @@ function genSelect (el: ASTElement, value: ?string) {
129
129
return true
130
130
}
131
131
132
- function checkOptionWarning ( option : ASTNode ) {
132
+ function checkOptionWarning ( option : any ) : boolean {
133
133
if ( option . type === 1 &&
134
134
option . tag === 'option' &&
135
135
option . attrsMap . selected != null ) {
136
- const parentModel = option . parent &&
137
- option . parent . type === 1 &&
138
- option . parent . attrsMap [ 'v-model' ]
139
136
warn (
140
- `<select v-model="${ parentModel } ">:\n` +
137
+ `<select v-model="${ option . parent . attrsMap [ 'v-model' ] } ">:\n` +
141
138
'inline selected attributes on <option> will be ignored when using v-model. ' +
142
139
'Declare initial values in the component\'s data option instead.'
143
140
)
144
141
return true
145
142
}
143
+ return false
146
144
}
0 commit comments