File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,15 @@ module.exports = {
11
11
if ( optionsParam ) {
12
12
initOptions . call ( this , optionsParam )
13
13
}
14
+ this . number = this . _checkParam ( 'number' ) != null
14
15
this . multiple = el . hasAttribute ( 'multiple' )
15
16
this . listener = function ( ) {
16
17
var value = self . multiple
17
18
? getMultiValue ( el )
18
19
: el . value
20
+ value = self . number
21
+ ? _ . toNumber ( value )
22
+ : value
19
23
self . set ( value , true )
20
24
}
21
25
_ . on ( el , 'change' , this . listener )
@@ -124,7 +128,9 @@ function checkInitialValue () {
124
128
}
125
129
}
126
130
if ( initValue ) {
127
- this . _initValue = initValue
131
+ this . _initValue = this . number
132
+ ? _ . toNumber ( initValue )
133
+ : initValue
128
134
}
129
135
}
130
136
Original file line number Diff line number Diff line change @@ -273,6 +273,30 @@ if (_.inBrowser) {
273
273
expect ( opts [ 2 ] . selected ) . toBe ( false )
274
274
} )
275
275
276
+ it ( 'select + number' , function ( ) {
277
+ var vm = new Vue ( {
278
+ el : el ,
279
+ data : {
280
+ test : '1'
281
+ } ,
282
+ template : '<select v-model="test" number><option value="1">1</option></select>'
283
+ } )
284
+ expect ( vm . test ) . toBe ( '1' )
285
+ trigger ( vm . $el . firstChild , 'change' )
286
+ expect ( vm . test ) . toBe ( 1 )
287
+ } )
288
+
289
+ it ( 'select + number initial value' , function ( ) {
290
+ var vm = new Vue ( {
291
+ el : el ,
292
+ data : {
293
+ test : '1'
294
+ } ,
295
+ template : '<select v-model="test" number><option value="1" selected>1</option></select>'
296
+ } )
297
+ expect ( vm . test ) . toBe ( 1 )
298
+ } )
299
+
276
300
it ( 'text' , function ( done ) {
277
301
var vm = new Vue ( {
278
302
el : el ,
You can’t perform that action at this time.
0 commit comments