Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/dom/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -839,19 +839,32 @@ p5.prototype.createRadio = function() {
// If already given with a containerEl, will search for all input[radio]
// it, create a p5.Element out of it, add options to it and return the p5.Element.

let self;
let radioElement;
let name;
const arg0 = arguments[0];
// If existing radio Element is provided as argument 0
if (arg0 instanceof HTMLDivElement || arg0 instanceof HTMLSpanElement) {
if (
arg0 instanceof p5.Element &&
(arg0.elt instanceof HTMLDivElement || arg0.elt instanceof HTMLSpanElement)
) {
// If given argument is p5.Element of div/span type
self = arg0;
this.elt = arg0.elt;
} else if (
// If existing radio Element is provided as argument 0
arg0 instanceof HTMLDivElement ||
arg0 instanceof HTMLSpanElement
) {
self = addElement(arg0, this);
this.elt = arg0;
radioElement = arg0;
if (typeof arguments[1] === 'string') name = arguments[1];
} else {
if (typeof arg0 === 'string') name = arg0;
radioElement = document.createElement('div');
self = addElement(radioElement, this);
this.elt = radioElement;
}
this.elt = radioElement;
let self = addElement(radioElement, this);
self._name = name || 'radioOption';

// setup member functions
Expand Down