Skip to content

Commit

Permalink
🐛 Fix setting value property on a <select> item not changing the …
Browse files Browse the repository at this point in the history
…selected option
  • Loading branch information
skerit committed Mar 3, 2024
1 parent 94c8c0b commit 68b5e2f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 2.3.19 (WIP)

* Fix setting `value` property on a `<select>` 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
Expand Down
16 changes: 15 additions & 1 deletion lib/dom/html_element.js
Expand Up @@ -186,7 +186,7 @@ Element.setProperty(function tabIndex() {
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 1.3.0
* @version 2.3.16
* @version 2.3.19
*
* @type {String}
*/
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion 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 <jelle@elevenways.be>",
"keywords": [
"template",
Expand Down

0 comments on commit 68b5e2f

Please sign in to comment.