-
-
Notifications
You must be signed in to change notification settings - Fork 11
this
should not be added to the scope bag
#40
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
this
should not be added to the scope bag
#40
Conversation
Is there another way to reference |
in tests, you can define this: test('...', function () {
class Foo extends Component {
hi = 'hi';
<template>{{this.hi}}</template>
}
} which is valid. |
What about test('...', function () {
this.hi = b;
tpl = <template>{{this.hi}}</template>
} |
I don't think that can be supported, setComponentTemplate would have to get a reference to that function first, and it's anonymous |
If |
well, the transform currently does
|
that is because its the hbs format.
though i'm nore sure what will happen when its in hbs format and then gets converted to wire format. So my question is: when is it converted to hbs format. I think normally it gets converted directly to wire format? |
In the present design of components, it's intentional that that doesn't work. Because that's a template-only component and template-only components never have a I don't think it's completely unreasonable to propose a change that would reclaim this unused piece of the namespace and make lexically-scoped |
No, if we decided to allow lexically scoped But also, there is existing API for how you pass
Disambiguating between these two and considering how it relates to the component manager API is why I'm saying this would require design work. |
That would be good. |
Oh yes, good point. The way that the instance So the way I'd summarize things right now is that |
@ef4 anything blocking this PR? we've have some great tangential discussion! 😅 |
Since we know how
this
works:we omit
this
from thescope
bag always, as it's a syntax error to do{ this }
we should still error if
this
shows up in a place wherethis
doesn't exist (outside of classes and functions)I couldn't figure out how to effectively do this that didn't have a ton of footguns, so I left it as an exercise for another time.
For example, this is an easy use case where we want to forbid this:
This could maybe be written more simply in the underlying APIs, getting around the
this
restriction altogether by forcing folks to alias the variable -- which maybe they could do in the inline version above as well 🤔But this implies that we need to remove some caching that we have in ember right now -- because we don't want to keep component references around forever -- because
wireUpElement
won't care about previous component bindings next time it's called, even though the precompileTemplate part will be totally static, we're making a new binding between the scope bag and new templateOnly() instance.In any case, I think it warrants discussion about how to make this work ergonomically before restricting
this
usage arbitrarilyThat's my morning, tangential, mind spew