Skip to content

defaultValue incorrectly (?) diffed against prerendered HTML #4340

@rschristian

Description

@rschristian
  • Check if updating to the latest Preact version resolves the issue

Describe the bug

Rendering an input with defaultValue set runs into a bit of an issue with prerendered HTML as the HTML element will have value set (sincce there's no defaultValue attribute), but when Preact goes to diff it against the corresponding JS, it will clear out value and set defaultValue on the element. If only defaultValue were set this wouldn't be an issue, but explicitly clearing out value means defaultValue doesn't do much of anything (to my knowledge).

Fiddled with it a bit, but haven't found a decently golfed solution yet. Need some way to skip setting value or set value & defaultValue when defaultValue is incoming (I think).

Bit of a weird situation that can be solved by using value tbh.

Related: denoland/fresh#2406

To Reproduce

Reproduction

Steps to reproduce the behavior:

  1. Open repro
  2. Notice input is empty
  3. Check console to see that while the defaultValue prop is set, value is now an empty string.

Expected behavior

Like if the component was rendered w/out pre-existing HTML, the value should be correctly set so the input contains the right content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions