File tree Expand file tree Collapse file tree 3 files changed +26
-9
lines changed
test/unit/specs/directives/public Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change 1
- import { isArray , toNumber , looseEqual } from '../../../util/index'
1
+ import {
2
+ inDoc ,
3
+ isArray ,
4
+ toNumber ,
5
+ looseEqual ,
6
+ nextTick
7
+ } from '../../../util/index'
2
8
3
9
export default {
4
10
@@ -39,11 +45,16 @@ export default {
39
45
// selectedIndex with value -1 to 0 when the element
40
46
// is appended to a new parent, therefore we have to
41
47
// force a DOM update whenever that happens...
42
- this . vm . $on ( 'hook:attached' , this . forceUpdate )
48
+ this . vm . $on ( 'hook:attached' , ( ) => {
49
+ nextTick ( this . forceUpdate )
50
+ } )
43
51
} ,
44
52
45
53
update ( value ) {
46
54
var el = this . el
55
+ if ( ! inDoc ( el ) ) {
56
+ return nextTick ( this . forceUpdate )
57
+ }
47
58
el . selectedIndex = - 1
48
59
var multi = this . multiple && isArray ( value )
49
60
var options = el . options
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__
13
13
14
14
// UA sniffing for working around browser-specific quirks
15
15
const UA = inBrowser && window . navigator . userAgent . toLowerCase ( )
16
+ export const isIE = UA && UA . indexOf ( 'trident' ) > 0
16
17
export const isIE9 = UA && UA . indexOf ( 'msie 9.0' ) > 0
17
18
export const isAndroid = UA && UA . indexOf ( 'android' ) > 0
18
19
export const isIos = UA && / ( i p h o n e | i p a d | i p o d | i o s ) / i. test ( UA )
Original file line number Diff line number Diff line change @@ -235,7 +235,7 @@ describe('v-model', function () {
235
235
} )
236
236
} )
237
237
238
- it ( 'select persist non-selected on append' , function ( ) {
238
+ it ( 'select persist non-selected on append' , function ( done ) {
239
239
var vm = new Vue ( {
240
240
el : el ,
241
241
data : {
@@ -249,12 +249,17 @@ describe('v-model', function () {
249
249
'<option>c</option>' +
250
250
'</select>'
251
251
} )
252
- expect ( vm . $el . value ) . toBe ( '' )
253
- expect ( vm . $el . selectedIndex ) . toBe ( - 1 )
254
- vm . $remove ( )
255
- vm . $appendTo ( document . body )
256
- expect ( vm . $el . value ) . toBe ( '' )
257
- expect ( vm . $el . selectedIndex ) . toBe ( - 1 )
252
+ _ . nextTick ( function ( ) {
253
+ expect ( vm . $el . value ) . toBe ( '' )
254
+ expect ( vm . $el . selectedIndex ) . toBe ( - 1 )
255
+ vm . $remove ( )
256
+ vm . $appendTo ( document . body )
257
+ _ . nextTick ( function ( ) {
258
+ expect ( vm . $el . value ) . toBe ( '' )
259
+ expect ( vm . $el . selectedIndex ) . toBe ( - 1 )
260
+ done ( )
261
+ } )
262
+ } )
258
263
} )
259
264
260
265
it ( 'select template default value' , function ( ) {
You can’t perform that action at this time.
0 commit comments