Skip to content

Commit 4a034e5

Browse files
author
mlarghydracept
committed
adding comments
1 parent 780841d commit 4a034e5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/addons/p5.dom.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -575,23 +575,29 @@
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;

0 commit comments

Comments
 (0)