diff --git a/source/js/dselect.js b/source/js/dselect.js index 8b67424..cd14be4 100644 --- a/source/js/dselect.js +++ b/source/js/dselect.js @@ -156,21 +156,28 @@ function dselect(el, option = {}) { } function itemTags(options) { - let items = [] - for (const option of options) { - if (option.tagName === 'OPTGROUP') { - items.push(``) + let items = []; + for (const option2 of options) { + if (option2.tagName === "OPTGROUP") { + items.push(``); } else { - const hidden = isPlaceholder(option) ? ' hidden' : '' - const active = option.selected ? ' active' : '' - const disabled = el.multiple && option.selected ? ' disabled' : '' - const value = option.value - const text = option.textContent - items.push(`${text}`) + const hidden = isPlaceholder(option2) ? " hidden" : ""; + const active = option2.selected ? " active" : ""; + const disabled = option2.selected ? " disabled" : ""; + const disabledvalue = option2.getAttribute("disabled") + disableitem = ''; + if (disabledvalue !== null) { + disableitem = "disabled='true'"; + } else { + disableitem = ""; + } + const value = option2.value; + const text = option2.textContent; + items.push(`${text}`); } } - items = items.join('') - return items + items = items.join(""); + return items; } function createDom() { @@ -222,4 +229,4 @@ function dselect(el, option = {}) { } el.addEventListener('change', updateDom) -} \ No newline at end of file +}