Skip to main content

set_attribute_value

Function set_attribute_value 

Source
pub fn set_attribute_value(node: i64, name: &str, value: &RuntimeValue)
Expand description

Set an attribute from a VALUE rather than from a string — the ONE place the boolean-attribute rule lives, so no two tiers can render disabled differently.

An HTML boolean attribute’s state is its PRESENCE: disabled="", disabled="disabled" and disabled="false" all disable the control, and the only way to say ENABLED is to leave the attribute out. So a Bool in one of those names decides presence and nothing is written when it is false; every other value is written as it always was, which is what keeps disabled="" (present, in HTML) and data-done={false} (data, so it keeps its text) both correct.

The rule is keyed on the value’s TYPE, not its truthiness — an empty Text is falsy and disabled="" is disabled, so a truthiness rule would drop exactly the case HTML keeps.