Skip to content

fix: use setters for spread props on customized built-in elements - #19035

Open
awss1i wants to merge 1 commit into
sveltejs:mainfrom
awss1i:customized-builtin-spread
Open

awss1i wants to merge 1 commit into
sveltejs:mainfrom
awss1i:customized-builtin-spread

Conversation

@awss1i

@awss1i awss1i commented Oct 17, 2026

Copy link
Copy Markdown

Closes #19034

When a customized built-in like <button is="fancy-button"> gets its props through a spread, get_attributes doesn't count it as a custom element, because it only checks the node name for a hyphen. So strings are written as attributes, null removes the attribute, and the element's setter never runs. Without a spread, the compiler already treats elements with an is attribute as custom elements, so the same props reach the setter through set_custom_element_data.

The custom element check now also looks for an is attribute. The __value branch keeps running for elements without a hyphen, since custom elements are only skipped there because Lit keeps its own value in that property. Without that, a select bound to spread option values that are objects gets the string "[object Object]", and typing "250.5" into a spread number input that is a customized built-in ends up as "5250".

Added a runtime-runes test with a customized built-in button that gets its label with and without a spread, including an update to null, and a select bound to customized built-in options with spread object values. On main it fails at the first spread assertion, and with only the custom element check changed it fails at the select. It passes with the change. The full test suite (7897 passed), lint and type check pass too.

Before submitting the PR, please make sure you do the following

  • 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
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

`get_attributes` only counted elements with a hyphen in their name as
custom elements, so a spread on `<button is="...">` wrote strings with
`setAttribute` and removed null values instead of calling the setter.
It now also checks for an `is` attribute, like the compiler does.

The `value`/`__value` branch keeps running for elements without a
hyphen, so customized built-in options and inputs keep their value
handling.
@pkg-svelte-dev

Copy link
Copy Markdown

Install the latest version of svelte from e36837f:

pnpm add https://pkg.svelte.dev/svelte/c/e36837fc14b79e35d67fc35e9f5c20ec9ab69815

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/svelte/pr/19035

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Oct 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e36837f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spread props on customized built-in elements skip their setters

1 participant