Moved option construction before setting element value.

This commit is contained in:
MattMo 2023-11-28 19:16:15 -08:00
parent 7f2b6465c2
commit 23f8fa5b72

View File

@ -1444,6 +1444,24 @@ class IgniteTemplate {
this.children[i].construct(this.element); this.children[i].construct(this.element);
} }
//Construct any options if needed
if (this._options.length > 0 && this._optionElements.length == 0) {
this._options.forEach(option => {
if (option) {
var element = window.document.createElement("option");
element.setAttribute("value", option.value);
element.innerHTML = option.name;
this._optionElements.push(element);
//Add this element to the dom.
if (this.element) {
this.element.appendChild(element);
}
}
});
}
//Set the elements value if there is one. //Set the elements value if there is one.
if (this._elementValue != null) { if (this._elementValue != null) {
if (this.element.hasAttribute("type") && (this.element.getAttribute("type").toLowerCase().trim() == "checkbox" || this.element.getAttribute("type").toLowerCase().trim() == "radio")) { if (this.element.hasAttribute("type") && (this.element.getAttribute("type").toLowerCase().trim() == "checkbox" || this.element.getAttribute("type").toLowerCase().trim() == "radio")) {
@ -1483,24 +1501,6 @@ class IgniteTemplate {
this._intersectObserver.observe(this.element); this._intersectObserver.observe(this.element);
} }
//Construct any options if needed
if (this._options.length > 0 && this._optionElements.length == 0) {
this._options.forEach(option => {
if (option) {
var element = window.document.createElement("option");
element.setAttribute("value", option.value);
element.innerHTML = option.name;
this._optionElements.push(element);
//Add this element to the dom.
if (this.element) {
this.element.appendChild(element);
}
}
});
}
//Invoke any custom constructors. //Invoke any custom constructors.
this._constructors.forEach(callback => callback(parent, sibling)); this._constructors.forEach(callback => callback(parent, sibling));