@@ -15,6 +15,7 @@ export default function model (
15
15
const modifiers = dir . modifiers
16
16
const tag = el . tag
17
17
const type = el . attrsMap . type
18
+
18
19
if ( process . env . NODE_ENV !== 'production' ) {
19
20
const dynamicType = el . attrsMap [ 'v-bind:type' ] || el . attrsMap [ ':type' ]
20
21
if ( tag === 'input' && dynamicType ) {
@@ -23,7 +24,16 @@ export default function model (
23
24
`v-model does not support dynamic input types. Use v-if branches instead.`
24
25
)
25
26
}
27
+ // inputs with type="file" are read only and setting the input's
28
+ // value will throw an error.
29
+ if ( tag === 'input' && type === 'file' ) {
30
+ warn (
31
+ `<${ el . tag } v-model="${ value } " type="file">:\n` +
32
+ `File inputs are read only. Use a v-on:change listener instead.`
33
+ )
34
+ }
26
35
}
36
+
27
37
if ( tag === 'select' ) {
28
38
genSelect ( el , value , modifiers )
29
39
} else if ( tag === 'input' && type === 'checkbox' ) {
@@ -33,6 +43,7 @@ export default function model (
33
43
} else {
34
44
genDefaultModel ( el , value , modifiers )
35
45
}
46
+
36
47
// ensure runtime directive metadata
37
48
return true
38
49
}
@@ -136,16 +147,6 @@ function genDefaultModel (
136
147
code = `if($event.target.composing)return;${ code } `
137
148
}
138
149
139
- // inputs with type="file" are read only and setting the input's
140
- // value will throw an error.
141
- if ( process . env . NODE_ENV !== 'production' &&
142
- type === 'file' ) {
143
- warn (
144
- `<${ el . tag } v-model="${ value } " type="file">:\n` +
145
- `File inputs are read only. Use a v-on:change listener instead.`
146
- )
147
- }
148
-
149
150
addProp ( el , 'value' , isNative ? `_s(${ value } )` : `(${ value } )` )
150
151
addHandler ( el , event , code , null , true )
151
152
if ( trim || number || type === 'number' ) {
0 commit comments