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

Preact/compat - Input value does not show up in the HTML #2675

Closed
christianpv opened this issue Aug 4, 2020 · 4 comments
Closed

Preact/compat - Input value does not show up in the HTML #2675

christianpv opened this issue Aug 4, 2020 · 4 comments

Comments

@christianpv
Copy link

christianpv commented Aug 4, 2020

Reproduction

Steps to reproduce

Type "anything" in the email input.

Expected Behavior

Inspecting the input element shows a value of "anything".

Actual Behavior

Inspecting the input element does not show a value.

Note

If the default value is an empty string, the input value appears as an empty string in React.
Screen Shot 2020-08-03 at 8 31 24 PM

@sventschui
Copy link
Member

Thank you for reporting this issue. This seems to be (kinda) expected behaviour as we are using different DOM APIs as react does and thus the browser devtools are not updated.

Would you mind sharing your usecase where this is an issue?

Note that this only affects getAttribute('value') but not .value:

image

image

@sventschui sventschui added the needs-more-info The issue doesn't contain enough information to be able to help label Aug 4, 2020
@developit
Copy link
Member

developit commented Aug 4, 2020

Hi @christianpv! Thanks for the issue, and thanks for the quick and accurate response @sventschui.

Just to echo: this is very much working-as-intended. The value of an input should never be reflected in the DOM, doing so is actually a known security vulnerability. Last time I looked into it, React plans to correct this behavior in their next major version.

For what it's worth, Preact does correctly render using the value="" attribute during SSR, where doing so is necessary and intended.

@developit developit added wontfix compat and removed needs-more-info The issue doesn't contain enough information to be able to help labels Aug 4, 2020
@christianpv
Copy link
Author

@developit Thanks for the quick reply. I ran into this issue when I tried to replace React with Preact. Some of our unit tests were not passing due to the value not rendering but this issue is not affecting us anymore since we rewrote the tests. Thanks again!

@developit
Copy link
Member

Awesome - thanks for the context, that's useful to know. It might be good for us to update the docs to cover this somehow.

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

No branches or pull requests

3 participants