-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Closed
Description
This is how I've been conditionally putting the disabled attribute on elements, with a boolean variable:
<input disabled={isDisabled} type=... />When isDisabled is falsey, the attribute won't be output. When true, it will output the following, which works in browsers but is against the HTML5 spec:
<input disabled="true" type=... />I could get in line with the spec by setting disabled="disabled" on the element, but that requires a ternary operation instead of a simple boolean:
<input disabled={isDisabled ? "disabled" : false} ... />Ideally, my current bit of JSX (at the top of this issue) would output this HTML, assuming disabled is set to true:
<input disabled type=... />More generally, if a known boolean attribute gets assigned a variable set to true as in my example, JSX should output just the attribute as per the HTML5 spec.
hozefaj, ruffin--, trusktr, pestevez, mnbbrown and 11 more
Metadata
Metadata
Assignees
Labels
No labels