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
For custom elements where the props and attributes are defined with <svelte:options/>, there appears to be an inconsistency in how Svelte handles props-to-attributes mapping depending on how the props are accessed.
letprops=$props();props.message;// undefinedprops["data-external-props-message"];// works, but requires using attribute name
When using destructuring:
let{ message }=$props();// works as expected
Correct me if I am wrong but I think props should be consistently accessible regardless of the method used to reference them, either through direct reference or destructuring.
Upon initial investigation, the issue seems to originate from here where the prop definition of the custom element is constructed based on the explicitly defined props of the component (see here). This worked in Svelte 4 because the props are always defined with export let message, however in svelte 5 where it is possible to define props like let props = $props(), properties will always be an empty array in this case.
We didn't account for the `$props` rune being writtin in a way that makes some props unknown, and they would only be visible through the `customElement.props` definition. This changes the iteration to account for that and also adds a note to the documentation that you need to list out the properties explicitly.
fixes#13785
Describe the bug
For custom elements where the props and attributes are defined with
<svelte:options/>
, there appears to be an inconsistency in how Svelte handles props-to-attributes mapping depending on how the props are accessed.When accessing props directly:
When using destructuring:
Correct me if I am wrong but I think props should be consistently accessible regardless of the method used to reference them, either through direct reference or destructuring.
Upon initial investigation, the issue seems to originate from here where the prop definition of the custom element is constructed based on the explicitly defined props of the component (see here). This worked in Svelte 4 because the props are always defined with
export let message
, however in svelte 5 where it is possible to define props likelet props = $props()
, properties will always be an empty array in this case.Reproduction
REPL
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: