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() {
705
705
}
706
706
//see if there is already an option with this name
707
707
for ( let i = 0 ; i < this . elt . length ; i += 1 ) {
708
- if ( this . elt [ i ] . innerHTML === name ) {
708
+ if ( this . elt [ i ] . textContent === name ) {
709
709
index = i ;
710
710
break ;
711
711
}
@@ -722,7 +722,7 @@ p5.prototype.createSelect = function() {
722
722
} else {
723
723
//if it doesn't exist create it
724
724
const opt = document . createElement ( 'option' ) ;
725
- opt . innerHTML = name ;
725
+ opt . textContent = name ;
726
726
opt . value = value === undefined ? name : value ;
727
727
this . elt . appendChild ( opt ) ;
728
728
this . _pInst . _elements . push ( opt ) ;
Original file line number Diff line number Diff line change @@ -807,6 +807,15 @@ suite('DOM', function() {
807
807
}
808
808
} ) ;
809
809
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
+
810
819
test ( 'calling selected(value) should updated selectedIndex' , function ( ) {
811
820
testElement = myp5 . createSelect ( true ) ;
812
821
options = [ 'Sunday' , 'Monday' , 'Tuesday' , 'Friday' ] ;
You can’t perform that action at this time.
0 commit comments