You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using custom elements as a child of a svelete component in svelte 5, attributes/props starting with 'on' get shadowed by the implicit remapping of on:foo to onfoo. For example, as seen in the repl, a property like oneworld which is expected to be a bool can't be used as a shorthand and returns null as a value even when explicitly setting it as true.
Perhaps Svelte could treat on-props as regular props for any non-standard elements?
Components don't treat on-props any differently than any other prop, so I don't see why this should be different for custom elements (or maybe instead of treating any attribute starting with on as an event handler, Svelte could have an array of valid HTML events and look for those instead).
While this is true, the general advice - outside of Svelte, too - is to not use properties/attributes starting with on. All JSX-based frameworks (like React etc) also rely on this convention.
Describe the bug
When using custom elements as a child of a svelete component in svelte 5, attributes/props starting with 'on' get shadowed by the implicit remapping of
on:foo
toonfoo
. For example, as seen in the repl, a property likeoneworld
which is expected to be a bool can't be used as a shorthand and returnsnull
as a value even when explicitly setting it astrue
.Reproduction
https://svelte.dev/playground/8e97714826aa4a0fb17c5aafef24bdc5?version=5.14.0
Logs
This is the error shown if you try to use the boolean property shorthand
e.g.
<custom-element oneworld foo={false}></custom-element>
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: