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 @@ -98,7 +98,12 @@ function initOptions (expression) {
98
98
while ( i -- ) {
99
99
var option = el . options [ i ]
100
100
if ( option !== defaultOption ) {
101
- el . removeChild ( option )
101
+ var parentNode = option . parentNode
102
+ if ( parentNode === el ) {
103
+ parentNode . removeChild ( option )
104
+ } else {
105
+ el . removeChild ( parentNode )
106
+ }
102
107
}
103
108
}
104
109
buildOptions ( el , value )
Original file line number Diff line number Diff line change @@ -341,8 +341,8 @@ if (_.inBrowser) {
341
341
expect ( opts [ 2 ] . selected ) . toBe ( true )
342
342
} )
343
343
344
- it ( 'select + options + optgroup' , function ( ) {
345
- new Vue ( {
344
+ it ( 'select + options + optgroup' , function ( done ) {
345
+ var vm = new Vue ( {
346
346
el : el ,
347
347
data : {
348
348
test : 'b' ,
@@ -365,6 +365,26 @@ if (_.inBrowser) {
365
365
expect ( opts [ 0 ] . selected ) . toBe ( false )
366
366
expect ( opts [ 1 ] . selected ) . toBe ( true )
367
367
expect ( opts [ 2 ] . selected ) . toBe ( false )
368
+ vm . opts = [
369
+ { label : 'X' , options : [ 'x' , 'y' ] } ,
370
+ { label : 'Y' , options : [ 'z' ] }
371
+ ]
372
+ vm . test = 'y'
373
+ _ . nextTick ( function ( ) {
374
+ expect ( el . firstChild . innerHTML ) . toBe (
375
+ '<optgroup label="X">' +
376
+ '<option value="x">x</option><option value="y">y</option>' +
377
+ '</optgroup>' +
378
+ '<optgroup label="Y">' +
379
+ '<option value="z">z</option>' +
380
+ '</optgroup>'
381
+ )
382
+ var opts = el . firstChild . options
383
+ expect ( opts [ 0 ] . selected ) . toBe ( false )
384
+ expect ( opts [ 1 ] . selected ) . toBe ( true )
385
+ expect ( opts [ 2 ] . selected ) . toBe ( false )
386
+ done ( )
387
+ } )
368
388
} )
369
389
370
390
it ( 'select + options with Object value' , function ( done ) {
You can’t perform that action at this time.
0 commit comments