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 with prior value not updating with setAttribute #359

Closed
rviscomi opened this issue Sep 8, 2015 · 0 comments · Fixed by #379
Closed

Input element with prior value not updating with setAttribute #359

rviscomi opened this issue Sep 8, 2015 · 0 comments · Fixed by #379
Labels

Comments

@rviscomi
Copy link
Member

rviscomi commented Sep 8, 2015

See this jsfiddle: https://jsfiddle.net/cbbpfven/

When an input element already has a value set (in this case, by el.value) updating that value via el.setAttribute doesn't change the displayed value. el.getAttribute returns the updated value, but el.value still shows the old value.

spf.dom.setAttributes is directly affected by this bug: https://github.com/youtube/spfjs/blob/master/src/client/dom/dom.js#L149

This could just be a Chrome bug, but we can work around it by reassigning el.value with the updated value.

@rviscomi rviscomi added the bug label Sep 8, 2015
@nicksay nicksay added this to the SPF 23 (v2.3.1) milestone Jan 6, 2016
nicksay added a commit to nicksay/spfjs that referenced this issue Jan 6, 2016
When setting an `input` element's `value` attribute via `el.setAttribute()`,
the displayed value is not updated, and the original value returned by
`el.value` instead of the new value.  To fix this, assign the `value` attribute
both ways.

Also, add tests to catch this problem.

Closes youtube#359.
nicksay added a commit to nicksay/spfjs that referenced this issue Jan 6, 2016
When setting an `input` element's `value` attribute via `el.setAttribute()`,
the displayed value is not updated, and the original value is returned by
`el.value` instead of the new value.  To fix this, assign the `value` attribute
both ways.

Also, add tests to catch this problem.

Closes youtube#359.
nicksay added a commit to nicksay/spfjs that referenced this issue Jan 6, 2016
When setting an `input` element's `value` attribute via `el.setAttribute()`,
the displayed value is not updated, and the original value is returned by
`el.value` instead of the new value.  To fix this, assign the `value` attribute
both ways.

Also, add tests to catch this problem.

Closes youtube#359.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants