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 = {
55 bind : function ( ) {
66 var self = this
77 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+ }
814 this . listener = function ( ) {
9- self . set ( el . value )
15+ self . set ( getValue ( ) )
1016 }
1117 _ . on ( el , 'change' , this . listener )
1218 if ( el . checked ) {
13- this . _initValue = el . value
19+ this . _initValue = getValue ( )
1420 }
1521 } ,
1622
Original file line number Diff line number Diff line change @@ -48,25 +48,25 @@ if (_.inBrowser) {
4848 var vm = new Vue ( {
4949 el : el ,
5050 data : {
51- test : 'a '
51+ test : '1 '
5252 } ,
5353 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">'
5656 } )
5757 expect ( el . childNodes [ 0 ] . checked ) . toBe ( true )
5858 expect ( el . childNodes [ 1 ] . checked ) . toBe ( false )
59- vm . test = 'b '
59+ vm . test = '2 '
6060 _ . nextTick ( function ( ) {
6161 expect ( el . childNodes [ 0 ] . checked ) . toBe ( false )
6262 expect ( el . childNodes [ 1 ] . checked ) . toBe ( true )
6363 el . childNodes [ 0 ] . click ( )
6464 expect ( el . childNodes [ 0 ] . checked ) . toBe ( true )
6565 expect ( el . childNodes [ 1 ] . checked ) . toBe ( false )
66- expect ( vm . test ) . toBe ( 'a' )
66+ expect ( vm . test ) . toBe ( 1 )
6767 vm . _directives [ 1 ] . unbind ( )
6868 el . childNodes [ 1 ] . click ( )
69- expect ( vm . test ) . toBe ( 'a' )
69+ expect ( vm . test ) . toBe ( 1 )
7070 done ( )
7171 } )
7272 } )
You can’t perform that action at this time.
0 commit comments