File tree 2 files changed +28
-3
lines changed
test/unit/specs/directives
2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,12 @@ function initOptions (expression) {
101
101
while ( i -- ) {
102
102
var option = el . options [ i ]
103
103
if ( option !== defaultOption ) {
104
- el . removeChild ( option )
104
+ var parentNode = option . parentNode
105
+ if ( parentNode === el ) {
106
+ parentNode . removeChild ( option )
107
+ } else {
108
+ el . removeChild ( parentNode )
109
+ }
105
110
}
106
111
}
107
112
buildOptions ( el , value )
Original file line number Diff line number Diff line change @@ -395,8 +395,8 @@ if (_.inBrowser) {
395
395
expect ( opts [ 2 ] . selected ) . toBe ( true )
396
396
} )
397
397
398
- it ( 'select + options + optgroup' , function ( ) {
399
- new Vue ( {
398
+ it ( 'select + options + optgroup' , function ( done ) {
399
+ var vm = new Vue ( {
400
400
el : el ,
401
401
data : {
402
402
test : 'b' ,
@@ -419,6 +419,26 @@ if (_.inBrowser) {
419
419
expect ( opts [ 0 ] . selected ) . toBe ( false )
420
420
expect ( opts [ 1 ] . selected ) . toBe ( true )
421
421
expect ( opts [ 2 ] . selected ) . toBe ( false )
422
+ vm . opts = [
423
+ { label : 'X' , options : [ 'x' , 'y' ] } ,
424
+ { label : 'Y' , options : [ 'z' ] }
425
+ ]
426
+ vm . test = 'y'
427
+ _ . nextTick ( function ( ) {
428
+ expect ( el . firstChild . innerHTML ) . toBe (
429
+ '<optgroup label="X">' +
430
+ '<option value="x">x</option><option value="y">y</option>' +
431
+ '</optgroup>' +
432
+ '<optgroup label="Y">' +
433
+ '<option value="z">z</option>' +
434
+ '</optgroup>'
435
+ )
436
+ var opts = el . firstChild . options
437
+ expect ( opts [ 0 ] . selected ) . toBe ( false )
438
+ expect ( opts [ 1 ] . selected ) . toBe ( true )
439
+ expect ( opts [ 2 ] . selected ) . toBe ( false )
440
+ done ( )
441
+ } )
422
442
} )
423
443
424
444
it ( 'select + options with Object value' , function ( done ) {
You can’t perform that action at this time.
0 commit comments