-
Notifications
You must be signed in to change notification settings - Fork 334
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
Set the boolean disabled
attribute consistently in the button component
#2830
Conversation
As flagged in #2828 (comment), there are a few edge cases where this could be considered a breaking change. Specifically, if a user is using if ($button.getAttribute('disabled') == 'disabled') {
// no longer works as getAttribute('disabled') on an element
// with <button disabled> returns an empty string
}
if ($button.getAttribute('disabled')) {
// no longer works as an empty string is falsey
} Depending on how likely we think this scenario is, we could either:
|
Another thing that the change may break besides app using JS to check if the button is disabled may be the fixtures for validating non JS implementations. Rails outputs boolean attributes in the disabled="disabled" form, I believe. Through its |
af801fb
to
a0de584
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this based on a discussion we had yesterday 🙌
But we also flagged the HTML living standard in reference to whether this is a breaking change or not from #2830 (comment)
2.3.2 Boolean attributes
https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
They give three examples considered valid:
<label><input type=checkbox checked name=cheese disabled> Cheese</label>
<label><input type=checkbox checked=checked name=cheese disabled=disabled> Cheese</label>
<label><input type='checkbox' checked name=cheese disabled=""> Cheese</label>
Although it might be breaking, we've essentially switched from "valid" to "also valid" ✅
Presumably this can now be merged given 4.6.0 has gone out, conflict notwithstanding. |
I need to add a changelog entry as well. |
Remove the value from the attribute so that we're setting boolean HTML attributes consistently across all components – matching what we're doing in the radios, checkboxes and select components. Re-enable the 'attribute-boolean-style' rule so that we enforce this going forward.
a0de584
to
2f8dfa2
Compare
I've rebased to resolve the conflict and added a changelog entry. |
2f8dfa2
to
c8c8f5a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
We fixed the current example in alphagov/govuk-frontend#2830
We fixed the current example in alphagov/govuk-frontend#2830
We fixed the current example in alphagov/govuk-frontend#2830
We fixed the current example in alphagov/govuk-frontend#2830
Remove the value from the attribute so that we're setting boolean HTML attributes consistently across all components – matching what we're doing in the radios, checkboxes and select components.
Re-enable the 'attribute-boolean-style' rule so that we enforce this going forward.
Split out from #2828.