-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[Bug] @foo !== this.args.foo (double helper eval) #19140
Comments
A (possibly) related bug: app/components/my-component/component.js import Component from '@glimmer/component';
export default class extends Component {
get isFooEqualToFoo() {
return this.args.foo === this.args.foo; // false 🤷♂️
}
} app/components/my-component/template.hbs isFooEqualToFoo = {{if this.isFooEqualToFoo "true" "false"}} app/templates/application.hbs <MyComponent @foo={{hash label="foo"}} /> |
I believe this may be fixed in the latest Ember release, can you check? Either way I would not have expected this to be the behavior in 3.20. The bug with |
@pzuraq I checked that this is still an issue in 3.21, as well as 3.22.0-beta.3 (even though the helper expressions seem to be lazily evaluated in the latter, they're still evaluated twice and |
I'm also seeing something similar (on 3.21): <SidePanel @heading={{foo "something"}}> And in P.S. I wouldn't notice that unless it was "bad". We do a bunch of stuff in this helper so the performance suffers and also memory leaks because of all the side-created stuff by the helper. |
@boris-petrov are you accessing it via |
I have just a single `@heading` in the template and that’s it, so it’s a bit different from the original issue. I can try reproducing it if you have troubles doing it yourself.
|
That would be very helpful, that seems very strange and different from the original report for sure. |
@pzuraq - here you go. It was too simple, not sure if I've made a mistake somewhere. There are two console-log's for a single call to the helper. |
This should be fixed on Ember master! It was fixed by #19258. Please let me know if this is still an issue! |
🐞 Describe the Bug
When a helper expression is used as the value for a given arg at the instantiation site of a Glimmer component, then said helper expression is evaluated twice, provided that said arg is consumed both through
@someArg
andthis.args.someArg
on the implementation side of said component.🔬 Minimal Reproduction
Ember twiddle here.
app/components/my-component/component.js
app/components/my-component/template.hbs
app/helpers/make-foo.js
app/templates/application.hbs
😕 Actual Behavior
Displays:
🤔 Expected Behavior
Should have displayed:
🌍 Environment
➕ Additional Context
We have a number of helpers that return object references as opposed to primitive values and these object references in many scenarios matter just as much as the properties they carry. For example the reference itself matters when added to / queried against (Weak)Map, (Weak)Set, or simply when performing
===
orObject.is
comparisons. As a result of this bug, on the one hand we have our component's template dealing with one object reference, potentially passing it down to child components, and then passing it back up to action handlers on our JS class, and on the other hand we have our JS class dealing with a wholly different object reference (both objects effectively carry the same properties).There are certainly a number of scenarios where I can see this discrepancy as harmless but I can also think of quite a few where this effectively breaks data-down in a big way.
The text was updated successfully, but these errors were encountered: