fix: set input type before spread value (#18345)
### Before submitting the PR, please make sure you do the following - [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] Prefix your PR title with `feat:`, `fix:`, `chore:`, or `docs:`. - [x] This message body should clearly illustrate what problems it solves. - [x] Ideally, include a test that fails without this PR but passes with it. - [x] If this PR changes code within `packages/svelte/src`, add a changeset (`npx changeset`). ### Tests and linting - [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` Fixes #18332. When spread props put `value` before a later `type="hidden"` on an `<input>`, `set_attributes` currently writes the value while the element is still a text input. Browsers sanitize text input values by removing newlines, so the hidden input permanently loses them before `type` is applied. This sets an input's `type` first whenever the same spread update also includes `value` or `__value`, so the existing value handling runs with the final input type. The new runtime-browser sample covers both the problematic spread-first order and the already-working type-first order. Validation: - `corepack pnpm lint` - `CI=1 corepack pnpm test` - `corepack pnpm vitest run packages/svelte/tests/runtime-browser/test.ts -t input-type-before-value-spread` --------- Co-authored-by: Rich Harris <rich.harris@vercel.com> Co-authored-by: Rich Harris <hello@rich-harris.dev>
J
jdoughty04 committed
378bb25097088c2277aa063408c62818cc1f6c4e
Parent: 2f6307a
Committed by GitHub <noreply@github.com>
on 5/31/2026, 4:16:37 PM