File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 5
5
6
6
import Watcher from '../../watcher'
7
7
import config from '../../config'
8
- import { assertProp , initProp } from '../../util/index'
8
+ import { assertProp , initProp , coerceProp } from '../../util/index'
9
9
10
10
const bindingModes = config . _propBindingModes
11
11
@@ -25,6 +25,7 @@ export default {
25
25
parent ,
26
26
parentKey ,
27
27
function ( val ) {
28
+ val = coerceProp ( prop , val )
28
29
if ( assertProp ( prop , val ) ) {
29
30
child [ childKey ] = val
30
31
}
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ function getIsBinding (el) {
76
76
77
77
export function initProp ( vm , prop , value ) {
78
78
const key = prop . path
79
+ value = coerceProp ( prop , value )
79
80
vm [ key ] = vm . _data [ key ] = assertProp ( prop , value )
80
81
? value
81
82
: undefined
@@ -143,6 +144,23 @@ export function assertProp (prop, value) {
143
144
return true
144
145
}
145
146
147
+ /**
148
+ * Force parsing value with coerce option.
149
+ *
150
+ * @param {* } value
151
+ * @param {Object } options
152
+ * @return {* }
153
+ */
154
+
155
+ export function coerceProp ( prop , value ) {
156
+ var coerce = prop . options . coerce
157
+ if ( ! coerce ) {
158
+ return value
159
+ }
160
+ // coerce is a function
161
+ return coerce ( value )
162
+ }
163
+
146
164
function formatType ( val ) {
147
165
return val
148
166
? val . charAt ( 0 ) . toUpperCase ( ) + val . slice ( 1 )
You can’t perform that action at this time.
0 commit comments