Skip to content
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

Angle components can't be rendered using the {{component}} helper #12590

Closed
renato-zannon opened this issue Nov 12, 2015 · 9 comments
Closed

Comments

@renato-zannon
Copy link

I'm experimenting with porting some components to angle bracket style in canary, and ended up stumbling on this. When I use {{component "my-angle-component"}} Ember errors out with:

Assertion Failed: You cannot invoke the 'my-angle-component' component with curly braces, because it's a subclass of GlimmerComponent. Please invoke it as '<my-angle-component>' instead.

which suggests that the {{component}} code path hasn't been prepared for angle components yet.

So, my questions are:

  1. Is this supposed to "just work", as if I had written <my-angle-component> in the first place? Or is there some higher-level definition pending to decide what the behavior should be?
  2. If the expected behavior here is the "obvious" one, is this something that someone new to the Ember codebase (though very familiar with Ember and JS in general) could work on? Or should I just go back to using curly components and wait? :)

Update: It seems to work alright if I use {{component "<my-angle-component>"}} (with requires some concating, in my case). Not sure if this is intentional though, I wasn't able to find any explicit tests for this case

@mixonic
Copy link
Sponsor Member

mixonic commented Nov 12, 2015

Is this supposed to "just work", as if I had written in the first place?

It should work as if you had invoked the glimmer component with angles. @Serabe was going to take a peek at this in spare time. Since angles are behind a FF we haven't been in a huge rush. But yeah, coordinating with @Serabe and helping with this would be welcome :-)

It seems to work alright if I use {{component "<my-angle-component>"}}

Haha, that is insane. That should not work. 😄

Also vaguely related is creating components with closures and ensuring those work: {{component (component 'some-glimmer-comp')}}

@renato-zannon
Copy link
Author

@mixonic Great! I'll try to whip up a PR in the next few days. From what I've seen it doesn't look too difficult :)

@rwjblue
Copy link
Member

rwjblue commented Nov 13, 2015

It seems to work alright if I use {{component ""}}

Haha, that is insane. That should not work.

Technically, it is fine (and what is actually expected by the component-node-manager).

If we want to allow {{component helper to invoke either angle bracket or curly bracket components we need a little more thought than just removing the assertion.

For example, when using {{component 'foo-bar' baz=blah}} this.attrs.baz would be a mutable object (because we auto-wrap with (mut helper in all curly bracket invocations).

@renato-zannon
Copy link
Author

@rwjblue Thanks for chiming in!

If we want to allow {{component helper to invoke either angle bracket or curly bracket components we need a little more thought than just removing the assertion.

I wasn't thinking about removing the assertion. Instead I intended to investigate whether it would be possible to make it work as if I had passed {{component "<my-angle-component>"}}. I do see your point about mutability though, so I assume this falls on the "needs higher level discussion" (and maybe RFC) category?

@rwjblue
Copy link
Member

rwjblue commented Nov 13, 2015

I wasn't thinking about removing the assertion. Instead I intended to investigate whether it would be possible to make it work as if I had passed {{component ""}}.

@renato-zannon - Ya, I wasn't trying to suggest you would take an improper shortcut. The fix for this specific thing (not requiring folks use <foo-bar> vs foo-bar) would be to make the node manager understand three states: curly, angle, and "doesn't matter", but we really need to nail down the mutability scenario before tackling that.

this falls on the "needs higher level discussion" (and maybe RFC) category?

I don't really think it needs an RFC, but I would like one of the angle bracket implementers to chime in so we can choose a path forward.

@wycats / @tomdale / @chancancode - What are your thoughts on angle brackets invoked from {{component 'foo-bar' blah=baz}}? Should app/components/foo-bar.js be allowed to be an Ember.GlimmerComponent? Should this.attrs.blahbe a mutable object or not? Other thoughts....

@mixonic
Copy link
Sponsor Member

mixonic commented Nov 13, 2015

I believe there was consensus that a GlimmerComponent could be used, and that auto-mut would not apply (normal glimmer component semantics).

@rwjblue
Copy link
Member

rwjblue commented Nov 13, 2015

I believe there was consensus that a GlimmerComponent could be used, and that auto-mut would not apply (normal glimmer component semantics).

A few notes:

  • Auto-mut happens as a compilation step, where we have absolutely no knowledge of the target. IOW, we don't know that one invocation of {{component is for a Ember.Component and another is for a Ember.GlimmerComponent.
  • At runtime after auto-(mut has been applied, we have no way currently to know if (mut was added by the auto-mut infrastructure or by the user in their template. This means that we cannot make {{component or (component "fix" (by removing the mutable object) the attrs. This could be fixed by adding a flag to (mut in the auto-mut.

@Serabe
Copy link
Member

Serabe commented Nov 13, 2015

Sorry for the delay. Tomorrow I'll be catching a flight to India, I'll b
there for two weeks and quite likely I'll have time to address this.

So far, I like @rwjblue's idea of marking the automut and "unboxing" it.
On Fri, 13 Nov 2015 at 20:49, Robert Jackson notifications@github.com
wrote:

I believe there was consensus that a GlimmerComponent could be used, and
that auto-mut would not apply (normal glimmer component semantics).

A few notes:

  • Auto-mut happens as a compilation step, where we have absolutely no
    knowledge of the target. IOW, we don't know that one invocation of
    {{component is for a Ember.Component and another is for a
    Ember.GlimmerComponent.
  • At runtime after auto-(mut has been applied, we have no way
    currently to know if (mut was added by the auto-mut infrastructure or
    by the user in their template. This means that we cannot make
    {{component or (component "fix" (by removing the mutable object) the
    attrs. This could be fixed by adding a flag to (mut in the auto-mut.


Reply to this email directly or view it on GitHub
#12590 (comment).

@locks
Copy link
Contributor

locks commented Apr 19, 2016

I am closing this issue as angle bracket components are currently being revisited and this issue might not be relevant anymore.
Feel free to re-open the issue if you think it's still justified, thank you!

@locks locks closed this as completed Apr 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants