-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Svelte 5: Spreading attributes to element breaks hidden
#11179
Comments
hidden
hidden
hidden
hidden
These are valid: <div hidden > <!-- same as hidden="hidden" -->
<div hidden=""> <!-- same as hidden="hidden" -->
<div hidden="hidden">
<div hidden="until-found"> Toggling between |
Understood @brunnerh, thanks for the clarification! I guess what is confusing is that the second The attribute is also typed in Svelte as |
@brunnerh currently, the TS type for the |
|
FWIW the same happens in Svelte 4 |
When spreading attributes, the setters of the element are checked. If they contain the key in question, it's set via that setter. For certain setters on certain elements this didn't work because the element prototype was not HTMLElement, rather a descendant of that (for example HTMLDivElement), which meant that only the setters of the descendant, not the superclass were taken into account. This fixes that by walking up the prototype chain until we find the Element prototype. fixes #11179
When spreading attributes, the setters of the element are checked. If they contain the key in question, it's set via that setter. For certain setters on certain elements this didn't work because the element prototype was not HTMLElement, rather a descendant of that (for example HTMLDivElement), which meant that only the setters of the descendant, not the superclass were taken into account. This fixes that by walking up the prototype chain until we find the Element prototype. fixes #11179
Describe the bug
When you have an element setup like this:
When
isHidden
changes,hidden
becomes"false"
, which is still hidden.If you remove the spread obj. from the attributes, if
hidden
isfalse
, it's removed from the attributes, making the element visible.So the issue is around the inconsistencies, as well as the type Svelte expects for the
hidden
attribute, which is currentlyboolean | null | undefined
, but should bestring | null | undefined
.Reproduction
REPL
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: