(id, options, isMultiSelect = false, appendEl)
| 20 | * @returns { DOM Node } selectEl - newly created select element |
| 21 | */ |
| 22 | export function buildSelect(id, options, isMultiSelect = false, appendEl) { |
| 23 | let selectEl = document.getElementById(id); |
| 24 | |
| 25 | if (selectEl) { return selectEl; } |
| 26 | |
| 27 | selectEl = document.createElement("select"); |
| 28 | let testingContainerEl = document.getElementById('testingContainer'); |
| 29 | // if nothing is passed, append to the normal container |
| 30 | if (!appendEl) { appendEl = testingContainerEl;} |
| 31 | |
| 32 | selectEl.id = id; |
| 33 | selectEl.multiple = isMultiSelect; |
| 34 | appendEl.appendChild(selectEl); |
| 35 | |
| 36 | options.forEach(option => { |
| 37 | let optionEl = document.createElement("option"); |
| 38 | |
| 39 | optionEl.value = option; |
| 40 | optionEl.text = option; |
| 41 | |
| 42 | selectEl.appendChild(optionEl); |
| 43 | }); |
| 44 | |
| 45 | return selectEl; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Create an iframe and append it to the testing container |
no outgoing calls
no test coverage detected