-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Component Boolean Arguments #407
Conversation
|
||
e.g. | ||
```hbs | ||
<Button @secondary /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possible drawback or unexpected consequence of this is that NOT passing @secondary
doesn't make the property false
but undefined. While it makes sense, if feels weird that instead of the usual true
/false
dichotomy we're dealing with true
/undefined
I'm not convinced if this small improvement is worth introducing another syntax that is:
Since I don't find the It's worth noticing that |
The main intention of this RFC is not to save few keystrokes but rather bring unison in how arguments work with how attribute works.
|
It's possible that I'm thinking of this incorrectly, but in my brain I understand the desire to make it function more like HTML however I think in this case it would be more confusing that passing an argument without a value somehow defaults the value to As an aside, I think that in HTML, valueless attributes that affect rendering or behavior do so by way of either css selectors ( For example, after adding button.attributes.hasOwnProperty('disabled')
true
button.attributes.disabled
disabled=""
button.getAttribute('disabled')
"" [Suggestion] So I guess what I think would be cool would be if this didn't set the value to tl;dr defaulting argument values to |
@hakubo I don't see bringing unison between attributes and arguments like a very desirable goal. Also at first glance this syntax reminds me a bit more more of positional arguments (which are not a thing in angle-bracket components, and IDK if they will ever be) than of valueless attributes. |
I agree with both @cibernox and @sdhull. First, I don't think that the current API ( Second, I would expect that While I don't think it'd be that big of a deal if it was supported, I think we should resist any new complexity to the API unless there's a clear win. |
@sdhull I understand the desire to make it function more like HTML however I think in this case it would be more confusing that passing an argument without a value somehow defaults the value to true." You might be coming from your experience with Ember templates and Angle Brackets as you know them currently. I strongly believe that for new comers, people that come from HTML, React, Vue, Polymer etc it would be natural to think that @cibernox "Also at first glance this syntax reminds me a bit more more of positional arguments (which are not a thing in angle-bracket components, and IDK if they will ever be) than of valueless attributes." It does because you know they existed. Again for new comers that would not be an issue. What will be an issue is a realization that they cannot use knowledge that they already posses about passing properties to HTML elements @barelyknown "Second, I would expect that <FooBar @baz>, if supported (which I'd oppose), would do something like , and though that would be more in line with my personal expectations, I'd rather it not be supported either given the limited gains and the movement towards tagless components.
What you're describing here IS possible but you do that with components attributes/properties not arguments. e.g. Ember started to position itself (as I get it) as a framework for people that do not have to know much about JavaScript, packaging, building an app etc. Framework that can be used by anyone that know HTML and for that reason I think it make sense for it to adhere to how 'normal' DOM attributes work. |
@sdhull
Similar to what is described here: https://developers.google.com/web/fundamentals/web-components/customelements but that feels clunky IMO |
@hakubo I like that better than defaulting the value to |
It is completely true that I agree with @hakubo that this is more aligned with how boolean attributes work, and having in mind that it works the same way in Vue and React, means that it is something that people are familiar with it. (even expect maybe) I think that the ergonomics of boolean arguments are super nice for UI <Modal @small @centered>
<Alert @info>....</Alert>
<Button @primary @big>Close</Button>
</Modal> |
Given the inactivity here I'm going to go ahead and close this. I apologize for the fact that this stagnated and if you would still like to try to move this forward, let me know and I'll ensure that it gets a proper review. |
Rendered