@@ -7,13 +7,22 @@ module.exports = {
7
7
var el = this . el
8
8
var trueExp = this . param ( 'true-exp' )
9
9
var falseExp = this . param ( 'false-exp' )
10
+ var number = this . param ( 'number' ) != null
10
11
var scope = this . _scope || this . vm
11
12
12
13
if ( process . env . NODE_ENV !== 'production' && ( trueExp || falseExp ) ) {
13
14
_ . deprecation . MODEL_EXP ( this . expression )
14
15
}
15
16
16
- this . _matchValue = function ( value ) {
17
+ this . getValue = function ( ) {
18
+ return el . hasOwnProperty ( '_value' )
19
+ ? el . _value
20
+ : number
21
+ ? _ . toNumber ( el . value )
22
+ : el . value
23
+ }
24
+
25
+ this . matchValue = function ( value ) {
17
26
if ( el . hasOwnProperty ( '_trueValue' ) ) {
18
27
return _ . looseEqual ( value , el . _trueValue )
19
28
} else if ( trueExp !== null ) {
@@ -43,7 +52,7 @@ module.exports = {
43
52
this . listener = function ( ) {
44
53
var model = self . _watcher . value
45
54
if ( _ . isArray ( model ) ) {
46
- var val = getValue ( el )
55
+ var val = self . getValue ( )
47
56
if ( el . checked ) {
48
57
if ( _ . indexOf ( model , val ) < 0 ) {
49
58
model . push ( val )
@@ -65,15 +74,9 @@ module.exports = {
65
74
update : function ( value ) {
66
75
var el = this . el
67
76
if ( _ . isArray ( value ) ) {
68
- el . checked = _ . indexOf ( value , getValue ( el ) ) > - 1
77
+ el . checked = _ . indexOf ( value , this . getValue ( ) ) > - 1
69
78
} else {
70
- el . checked = this . _matchValue ( value )
79
+ el . checked = this . matchValue ( value )
71
80
}
72
81
}
73
82
}
74
-
75
- function getValue ( el ) {
76
- return el . hasOwnProperty ( '_value' )
77
- ? el . _value
78
- : el . value
79
- }
0 commit comments