From eb3ed065a2345bc1f4ae042dfa4d2581b3540e61 Mon Sep 17 00:00:00 2001 From: MattMo Date: Mon, 12 Dec 2022 21:10:55 -0800 Subject: [PATCH] Added code to select the first option in a select element if the new value is null or empty. --- ignite-template.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ignite-template.js b/ignite-template.js index 75ae708..f7f8278 100644 --- a/ignite-template.js +++ b/ignite-template.js @@ -1337,6 +1337,12 @@ class IgniteTemplate { if (this.element.textContent != newValue.toString()) { this.element.textContent = newValue.toString(); } + } else if (this.element instanceof HTMLSelectElement) { + if (newValue == null || newValue == undefined || newValue == '') { + this.element.value = this.element.options[0].value; + } else if (this.element.value != newValue) { + this.element.value = newValue; + } } else { if (this.element.value != newValue) { this.element.value = newValue;