File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,18 @@ module.exports = {
5
5
bind : function ( ) {
6
6
var self = this
7
7
var el = this . el
8
+ var number = this . _checkParam ( 'number' ) != null
9
+ function getValue ( ) {
10
+ return number
11
+ ? _ . toNumber ( el . value )
12
+ : el . value
13
+ }
8
14
this . listener = function ( ) {
9
- self . set ( el . value )
15
+ self . set ( getValue ( ) )
10
16
}
11
17
_ . on ( el , 'change' , this . listener )
12
18
if ( el . checked ) {
13
- this . _initValue = el . value
19
+ this . _initValue = getValue ( )
14
20
}
15
21
} ,
16
22
Original file line number Diff line number Diff line change @@ -48,25 +48,25 @@ if (_.inBrowser) {
48
48
var vm = new Vue ( {
49
49
el : el ,
50
50
data : {
51
- test : 'a '
51
+ test : '1 '
52
52
} ,
53
53
template :
54
- '<input type="radio" value="a " v-model="test" name="test">' +
55
- '<input type="radio" value="b " v-model="test" name="test">'
54
+ '<input type="radio" value="1 " v-model="test" name="test" number >' +
55
+ '<input type="radio" value="2 " v-model="test" name="test">'
56
56
} )
57
57
expect ( el . childNodes [ 0 ] . checked ) . toBe ( true )
58
58
expect ( el . childNodes [ 1 ] . checked ) . toBe ( false )
59
- vm . test = 'b '
59
+ vm . test = '2 '
60
60
_ . nextTick ( function ( ) {
61
61
expect ( el . childNodes [ 0 ] . checked ) . toBe ( false )
62
62
expect ( el . childNodes [ 1 ] . checked ) . toBe ( true )
63
63
el . childNodes [ 0 ] . click ( )
64
64
expect ( el . childNodes [ 0 ] . checked ) . toBe ( true )
65
65
expect ( el . childNodes [ 1 ] . checked ) . toBe ( false )
66
- expect ( vm . test ) . toBe ( 'a' )
66
+ expect ( vm . test ) . toBe ( 1 )
67
67
vm . _directives [ 1 ] . unbind ( )
68
68
el . childNodes [ 1 ] . click ( )
69
- expect ( vm . test ) . toBe ( 'a' )
69
+ expect ( vm . test ) . toBe ( 1 )
70
70
done ( )
71
71
} )
72
72
} )
You can’t perform that action at this time.
0 commit comments