File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 575575 }
576576 self . option = function ( name , value ) {
577577 var index ;
578+ //see if there is already an option with this name
578579 for ( var i = 0 ; i < this . elt . length ; i ++ ) {
579580 if ( this . elt [ i ] . innerHTML == name ) {
580- index = i ;
581- break ;
581+ index = i ;
582+ break ;
582583 }
583584 }
585+ //if there is an option with this name we will modify it
584586 if ( index !== undefined ) {
587+ //if the user passed in false then delete that option
585588 if ( value === false ) {
586589 this . elt . remove ( index ) ;
587590 } else {
591+ //otherwise if the name and value are the same then change both
588592 if ( this . elt [ index ] . innerHTML == this . elt [ index ] . value ) {
589593 this . elt [ index ] . innerHTML = this . elt [ index ] . value = value ;
594+ //otherwise just change the value
590595 } else {
591596 this . elt [ index ] . value = value ;
592597 }
593598 }
594599 }
600+ //if it doesn't exist make it
595601 else {
596602 var opt = document . createElement ( 'option' ) ;
597603 opt . innerHTML = name ;
You can’t perform that action at this time.
0 commit comments