WebReflection / uhtml

A micro HTML/SVG render

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

input element does not show updated value

sladiri opened this issue · comments

I have a stackblitz here: https://codepen.io/sladiri/pen/gOPdjee

If you change the value via the spinners and then click the reset button, the input stays the same, although the value changed. It happens with text input as well.

it's .value=${...}, as you want to change the value, not set just the attribute 👋

Thank you very much for the explanation, I missed that.

To extend the explanation, this is how the DOM works, no library used:

document.body.innerHTML = `<input value="before">`;
// "<input value=\"before\">";
document.body.firstElementChild.value = 'after';
document.body.firstElementChild.value; // "after"
document.body.firstElementChild.getAttribute('value'); // "before"

the attribute does not reflect the value you'd set via JS, it's always the same attribute 👋