Can someone explain to me why if I create input component in Svelte, using html input like, for example
<input type="text" id="testId" name="name" value="random text">
the value attribute doesn't render in DOM? However the value property is in the element and its value can be picked up but for some reason I would like to know why there is no value attribute rendered. It's the same for type="number" but for type="hidden" value attribute renders OK.
In the current codebase (for upcoming v5) there is a function called remove_input_attr_defaults
with this documentation:
The value/checked attribute in the template actually corresponds to the defaultValue property, so we need to remove it upon hydration to avoid a bug when someone resets the form value.
This reasoning is a bit odd, since this might be exactly what people expect: That it resets to the given value.
Related issue: https://github.com/sveltejs/svelte/issues/8220
As of now, it will set the attribute in v5 for fully static values (see this comment).