-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
Support html attributes in angle bracket components #293
Support html attributes in angle bracket components #293
Conversation
@@ -7,6 +7,7 @@ | |||
disabled={{disabled}} | |||
onchange={{action "change" value="target.files"}} | |||
hidden |
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.
Can these other attributes be removed in this template since they are now passed in as regular HTML attributes?
accept={{accept}}
capture={{capture}}
multiple={{multiple}}
disabled={{disabled}}
Or perhaps they can just be given defaults in the template and then the ...attributes
will override them?
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.
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.
The current implementation is classic component classes which support the angle bracket invocation syntax.
Important to remember that these are separate concepts in ember:
- component type/class (classic or glimmer)
- component invocation (curly or angle)
I think that classic components are a more flexible implementation for now since it supports both new and older ember apps.
I just read the ember-angle-bracket-invocation-polyfill
docs and it seems like the polyfill itself supports ...attritubes
, but using them within our own component template may mean we no longer support curly invocation.
Maybe we could move ember-angle-bracket-invocation-polyfill
from devDependencies
to dependencies
. That might give us a hybrid solution.
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.
@gilest I fear you are missing inner-html vs outer-html in your concepts. Components using inner-html (@ember/component
without tagName: ''
) do not play well together with ...attributes
cause the HTML attributes passed on invocation would be set on the the element defined by component and on the elements that have ...attributes
.
E.g. if you have a component <FormElement>
like this:
export default Component.extend({
tagName: 'label',
});
<input ...attributes>
And you invoke it with <FormElement required />
the rendered HTML would be:
<label required>
<input required>
</label>
That's not what you want in most cases.
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.
You're right that's an important distinction! I think tagName: ''
was kind of discouraged but I've used it a lot myself.
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.
@mcfiredrill Thanks for starting the work on this one!
As @knownasilya pointed out here #292 (comment) the components needs to be refactored to tagless components cause otherwise HTML attributes are applied to the tag defined by them as well.
@@ -7,6 +7,7 @@ | |||
disabled={{disabled}} | |||
onchange={{action "change" value="target.files"}} | |||
hidden |
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.
Sounds good. Seems like I could move the Will need to refactor away from using |
Is it necessary for the label to wrap around the entire template, as in the current implementation? |
Oh, I wasn't aware of this. The main question seems to be: Should we support changing the tag of I think we should ship valid HTML and drop that use case at all. Valid HTML would also be not wrapping input by label but assigning them to each user using |
FWIW this is already looking to be a breaking change.
👍 for valid HTML. |
That said I think I don't 100% understand why the component was implemented as a |
Yeah I think the We should make sure we follow the spec closely here for usability and accessibility. |
@mcfiredrill Love the enthusiasm you're bringing 👍 But this is a pretty long-running addon, and I think supporting legacy apps and curly invocation is something we should keep doing for a while yet. |
@gilest Thanks a lot for your feedback! I haven't looked at it much yet so I'm going to investigate what benefits using ember-angle-bracket-invocation-polyfill in dependencies would bring. I am thinking to maybe follow this advice, and not worry about supporting html attributes for now. I may open a new PR or just totally redo this one. |
The polyfill is currently included in Moving it to
Sounds like a good approach 👍 |
Hmm I'm confused, I see the link on github (actually a 404) saying the build failed. |
@mcfiredrill Please push again – we're on GitHub actions now 😅 |
@gilest Nice! Merged master. |
Tests are passing but I'm trying to remember exactly what I was trying to do with this PR (nearly 3 years ago!), and it looks like I wanted to re-do at least a large portion of it.
|
Both FileDropzone and FileUpload implement splattributes since #514 which has been released as 4.1.0-beta.0 |
Support for angle bracket components.
docs: #292
I know at the least
...attributes
needs to be added to the template, I'm still working out if any other code can be removed or if anything else is needed.