Skip to content

The part about "boolean attributes" can be more clear. #711

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

Closed
oebrab opened this issue Nov 25, 2020 · 3 comments · Fixed by #745
Closed

The part about "boolean attributes" can be more clear. #711

oebrab opened this issue Nov 25, 2020 · 3 comments · Fixed by #745
Assignees

Comments

@oebrab
Copy link

oebrab commented Nov 25, 2020

The doc about boolean attributes says:

If isButtonDisabled has the value of null or undefined, the disabled attribute will not even be included in the rendered <button> element.

To be more clear, not only null or undefined, all falsy values mean not disabled, while all truthy values mean disabled.

@skirtles-code
Copy link
Contributor

I think there may be even more nuance lurking beneath the surface here.

From what I can tell:

  • Normal (non-boolean) attributes will be omitted if their value is undefined or null. All other values are converted to strings.
  • For boolean attributes the values undefined, null, false, 0 and NaN will lead to the attribute being omitted. All other values, including an empty string, will result in the attribute being included, though without a value.

@oebrab
Copy link
Author

oebrab commented Nov 25, 2020

Thanks! Learned a lot.

@skirtles-code skirtles-code self-assigned this Dec 11, 2020
@skirtles-code
Copy link
Contributor

I'm going to have a go at updating this unless I hear otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants