-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Regression: boolean attributes are no longer removed if value is false if attr name contains a dash #3790
Comments
Hi, |
@krskrs yeah I can see how this fixes compat with React but at the same time introduces issues for projects that rely on the old behaviour. My main reason for opening this ticket is to point that out and to make sure the team is aware that they didn't just fix a bug (unless the old behaviour truly was unintentional - the fix may still break sites but at least then those sites just relied on the effects of the bug, not actual intended behaviour) |
see #3717 |
@rejhgadellaa We are aware of this and I want to apologise for it, I did not account for this breaking behavior but thinking about it both unit tests and manual dom lookups could have suffered because of it. |
Related, more syntax control would solve this: |
Let's track this in #4416 |
Describe the bug
Preact 10.11.1 introduced the following change:
Related issue #3717 and PR #3720
To Reproduce
With preact 10.11.0, the following snippet:
would result in either a
<div />
with or without the attribute:but starting in 10.11.1, it results in:
Expected behavior
I was relying on the old behaviour for style rules so, at least in my use-case, this change could be considered a regression. The following CSS selector now always applies:
where previously it would only apply if the prop's value was
true
.The old behaviour feels more like HTML spec for boolean attributes/properties, but I'm not sure this applies to
data-
attributes?For example, I think
element.dataset.hasToolbar
will always return a string where boolean properties-derived-from-attributes likeelement.required
and-.disabled
will actually return a boolean in javascript.I can also see how it's worthwhile following React's behaviour here. They've actually recently fixed an issue and adopted Preact's behaviour for boolean attributes without dashes: facebook/react#9230
The text was updated successfully, but these errors were encountered: