File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,12 @@ function initOptions (expression) {
9898 while ( i -- ) {
9999 var option = el . options [ i ]
100100 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+ }
102107 }
103108 }
104109 buildOptions ( el , value )
Original file line number Diff line number Diff line change @@ -341,8 +341,8 @@ if (_.inBrowser) {
341341 expect ( opts [ 2 ] . selected ) . toBe ( true )
342342 } )
343343
344- it ( 'select + options + optgroup' , function ( ) {
345- new Vue ( {
344+ it ( 'select + options + optgroup' , function ( done ) {
345+ var vm = new Vue ( {
346346 el : el ,
347347 data : {
348348 test : 'b' ,
@@ -365,6 +365,26 @@ if (_.inBrowser) {
365365 expect ( opts [ 0 ] . selected ) . toBe ( false )
366366 expect ( opts [ 1 ] . selected ) . toBe ( true )
367367 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+ } )
368388 } )
369389
370390 it ( 'select + options with Object value' , function ( done ) {
You can’t perform that action at this time.
0 commit comments