Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input element does not show updated value #21

Closed
sladiri opened this issue Jul 15, 2020 · 3 comments
Closed

input element does not show updated value #21

sladiri opened this issue Jul 15, 2020 · 3 comments
Labels
invalid This doesn't seem right

Comments

@sladiri
Copy link

sladiri commented Jul 15, 2020

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.

@WebReflection
Copy link
Owner

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

@WebReflection WebReflection added the invalid This doesn't seem right label Jul 15, 2020
@sladiri
Copy link
Author

sladiri commented Jul 15, 2020

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

@WebReflection
Copy link
Owner

WebReflection commented Jul 15, 2020

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 👋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants