From 68b5e2fef461ebb0a3274797f1f91095dcccba5c Mon Sep 17 00:00:00 2001 From: Jelle De Loecker Date: Sun, 3 Mar 2024 15:58:14 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20setting=20`value`=20proper?= =?UTF-8?q?ty=20on=20a=20`` item not changing the selected option + ## 2.3.18 (2024-02-25) * Add `setGlobal`, `getGlobal` and `hasGlobal` methods to the `Hawkejs` class, for setting "global" variables that are available to all templates diff --git a/lib/dom/html_element.js b/lib/dom/html_element.js index 2d020d65..7ce85dc6 100644 --- a/lib/dom/html_element.js +++ b/lib/dom/html_element.js @@ -186,7 +186,7 @@ Element.setProperty(function tabIndex() { * * @author Jelle De Loecker * @since 1.3.0 - * @version 2.3.16 + * @version 2.3.19 * * @type {String} */ @@ -215,6 +215,20 @@ Element.setProperty(function value() { } this.textContent = value; + } else if (this.tagName == 'SELECT') { + let options = this.querySelectorAll('option'), + option, + i; + + for (i = 0; i < options.length; i++) { + option = options[i]; + + if (option.value == value) { + option.selected = true; + } else { + option.selected = false; + } + } } else { if (HAS_VALUE[this.tagName]) { return this.setAttribute('value', value); diff --git a/package.json b/package.json index 0d91ed94..09ca2005 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "hawkejs", "description": "Asynchronous Embedded JavaScript templates", - "version": "2.3.18", + "version": "2.3.19-alpha", "author": "Jelle De Loecker ", "keywords": [ "template",