- Start Date: 11/30/2018
- RFC PR: (leave this empty)
- Ember Issue: (leave this empty)
This RFC proposes to add a boolean argument to components, that aligns with boolean attribute of regular DOM elements.
Currently to pass a boolean property to a component a developer has to explicitly pass true
as an argument.
e.g.
This does allow the value to be a variable e.g.
If the value is not a variable {{}}
can actually be ommited as a true
string is truthy leading to somewhat easier to remember syntax of
Since this is hacky, one have to remember that
would not work as @bool=false
would pass a false
as string that is truthy in JavaScript.
For simple usecases it is verbose to write and does not align with HTML attributes like disabled
of which value can be ommited as desribed in HTML Spec
This RFC proposes that if an argument is passed without any value it should have a value true
set inside of a component.
e.g.
inside the Button component @secondary
should equal to true
.
e.g.
should render as
<button class="is-secondary">
Button
</button>
This would align with how attributes behave currently. Given an Input component:
if it is invoked like this:
it will render as
<input disabled>
This should be included in guides and also should be easier to teach as it is inline with HTML spec for attributes.
Can't think of any at the moment.
- In both React and Vue if a prop is passed with no value it is truthy inside of a component.
None at the moment.