glimmerjs / glimmer-application

[MOVED] This package is now part of the Glimmer.js monorepo
https://github.com/glimmerjs/glimmer.js
30 stars 13 forks source link

Infinite loop when observing 'args' in a computed property that returns an array that is iterated over by {{#each}} #50

Closed DecayConstant closed 6 years ago

DecayConstant commented 7 years ago
import Component, {tracked} from "@glimmer/component";
export default class MyComponent extends Component {
    @tracked('args') get arrayTest() {
        console.log('bye');
        return [1, 2];
    }
};
<div>
    {{#each arrayTest key='@index' as |num|}}
         {{num}}
    {{/each}}
</div>

With the above component, and template, the computed property gets recomputed in an infinite loop. You'll see bye in the console forever.

If you remove {{num}} from the inside of the {{#each}}, the infinite loop does not happen.

pittst3r commented 7 years ago

Thank you! Good find!

Ping @tomdale

CvX commented 7 years ago

(duplicate of #43)

tomdale commented 7 years ago

This is a bad bug. Making args a tracked property is probably wrong because it means every time we set it during rerender we schedule a rerender. Probably we want to manually dirty the args tag instead of using a tracked property which installs a setter that schedules a rerender.

tomdale commented 6 years ago

This got fixed awhile ago. Thank you for reporting!