-
Notifications
You must be signed in to change notification settings - Fork 192
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
[BUGFIX] Prevent accidental dynamic component lookup #1152
Conversation
2a8fb00
to
cdff060
Compare
|
||
if (DEBUG && !isCurriedComponentDefinition(value)) { | ||
throw new Error( | ||
`A curried component definition. You may have accidentally done <this.dynamicComponent>, where dynamicComponent was a string instead of a curried component definition. You must use the {{component}} helper to create a component definition when invoking dynamically.` |
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.
is it possible to use real path / value for error?
one more use case is: (emberjs/ember.js#18686)
{{#let "my-component" as |AnyComponent|}}
<AnyComponent />
{{/let}}
{{#let (hash AnyComponent="my-component") as |ctx|}}
<ctx.AnyComponent />
{{/let}}
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.
Updated the error message to reference the debugLabel of the reference, which should give better context in general.
Re: the use case, that is what we are trying to prevent, and is not a valid use case in general. You should convert forward to:
{{#let (hash AnyComponent=(component "my-component")) as |ctx|}}
<ctx.AnyComponent />
{{/let}}
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.
I know it not valid, my point is to have debug information pointing to such usage in case of error :)
(error may appear not only in this/@.foo
invocation)
Dynamic components invoked via `{{component}}` share a codepath with ones invoked via `<this.foo>`, and because of that currently if `<this.foo>` is a referring to a string, it will dynamically lookup the component. This is not expected behavior, and this PR prevents it by using a different, more restricted opcode for these lookups.
cdff060
to
a8b53cd
Compare
Dynamic components invoked via
{{component}}
share a codepath withones invoked via
<this.foo>
, and because of that currently if<this.foo>
is a referring to a string, it will dynamically lookup thecomponent. This is not expected behavior, and this PR prevents it by
using a different, more restricted opcode for these lookups.
Closes #1149
Addresses emberjs/ember.js#17744