File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -705,7 +705,7 @@ p5.prototype.createSelect = function() {
705705 }
706706 //see if there is already an option with this name
707707 for ( let i = 0 ; i < this . elt . length ; i += 1 ) {
708- if ( this . elt [ i ] . innerHTML === name ) {
708+ if ( this . elt [ i ] . textContent === name ) {
709709 index = i ;
710710 break ;
711711 }
@@ -722,7 +722,7 @@ p5.prototype.createSelect = function() {
722722 } else {
723723 //if it doesn't exist create it
724724 const opt = document . createElement ( 'option' ) ;
725- opt . innerHTML = name ;
725+ opt . textContent = name ;
726726 opt . value = value === undefined ? name : value ;
727727 this . elt . appendChild ( opt ) ;
728728 this . _pInst . _elements . push ( opt ) ;
Original file line number Diff line number Diff line change @@ -807,6 +807,15 @@ suite('DOM', function() {
807807 }
808808 } ) ;
809809
810+ test ( 'should update select value when HTML special characters are in the name' , function ( ) {
811+ testElement = myp5 . createSelect ( true ) ;
812+ testElement . option ( '&' , 'foo' ) ;
813+ assert . equal ( testElement . elt . options . length , 1 ) ;
814+ assert . equal ( testElement . elt . options [ 0 ] . value , 'foo' ) ;
815+ testElement . option ( '&' , 'bar' ) ;
816+ assert . equal ( testElement . elt . options [ 0 ] . value , 'bar' ) ;
817+ } ) ;
818+
810819 test ( 'calling selected(value) should updated selectedIndex' , function ( ) {
811820 testElement = myp5 . createSelect ( true ) ;
812821 options = [ 'Sunday' , 'Monday' , 'Tuesday' , 'Friday' ] ;
You can’t perform that action at this time.
0 commit comments