💬 RFC
As I understand the boolean mode of the @attr decorator is meant to replicate the semantics of the boolean html attributes, like disabled.
MDN says:
Note: The strings "true" and "false" are invalid values. To set the attribute to false, the attribute should be omitted altogether. Though modern browsers treat any string value as true, you should not rely on that behavior.
My request for comments is about what the behavior of FAST should be for these attributes. Right now FAST will treat an attribute like disabled="false" as having the value false. This does not match the behavior for native elements. This is often disguised (e.g. in Fluent UI WC) because this will match a CSS selector with [disabled]. This can lead to inconsistent behavior across components or even within a component. Perhaps these should be considered bugs within the implementor, but if the aim is to support semantics that are close to "native" I think any component library built with FAST would want semantics that match how most browsers will treat this situation, which is to interpret disabled="false" as true.
💻 Repro or Code Sample
@attr(mode: "boolean")
public disabled?: boolean;
You can see this behavior with the Fluent UI WC.
🤔 Expected Behavior
When the element has the attribute disabled="false" the disabled attribute on the class instance should be set to true.
😯 Current Behavior
The string "false" is interpreted as falsey, and the value of disabled is set to false.
💁 Possible Solution
Another possible solution would be to set the value to undefined, which more accurately matches the spec. However, this is still problematic for component library authors who need to specifically handle this value and avoid using selectors like [disabled] in their CSS.
🔦 Context
We implement a component library, similar to Fluent UI. Almost all components have a disabled attribute. CSS usually behaves as we want, but we have to take extra precautions in code to avoid treating disabled="false" differently than CSS. Essentially, we cannot use the built-in mode: "boolean" mode.
🌍 Your Environment
Reproduced in all versions of FAST 2.0 as far as I can tell.
💬 RFC
As I understand the boolean mode of the @attr decorator is meant to replicate the semantics of the boolean html attributes, like
disabled.MDN says:
Note: The strings "true" and "false" are invalid values. To set the attribute to false, the attribute should be omitted altogether. Though modern browsers treat any string value as true, you should not rely on that behavior.
My request for comments is about what the behavior of FAST should be for these attributes. Right now FAST will treat an attribute like
disabled="false"as having the valuefalse. This does not match the behavior for native elements. This is often disguised (e.g. in Fluent UI WC) because this will match a CSS selector with[disabled]. This can lead to inconsistent behavior across components or even within a component. Perhaps these should be considered bugs within the implementor, but if the aim is to support semantics that are close to "native" I think any component library built with FAST would want semantics that match how most browsers will treat this situation, which is to interpretdisabled="false"astrue.💻 Repro or Code Sample
You can see this behavior with the Fluent UI WC.
🤔 Expected Behavior
When the element has the attribute
disabled="false"thedisabledattribute on the class instance should be set totrue.😯 Current Behavior
The string
"false"is interpreted as falsey, and the value ofdisabledis set to false.💁 Possible Solution
Another possible solution would be to set the value to
undefined, which more accurately matches the spec. However, this is still problematic for component library authors who need to specifically handle this value and avoid using selectors like[disabled]in their CSS.🔦 Context
We implement a component library, similar to Fluent UI. Almost all components have a
disabledattribute. CSS usually behaves as we want, but we have to take extra precautions in code to avoid treatingdisabled="false"differently than CSS. Essentially, we cannot use the built-inmode: "boolean"mode.🌍 Your Environment
Reproduced in all versions of FAST 2.0 as far as I can tell.