Skip to content

Commit

Permalink
Release reference to root components after destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchlloyd committed Jul 16, 2017
1 parent 099d112 commit bd60d85
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/ember-glimmer/lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class Renderer {
let root = roots[i];
if (root.isFor(view)) {
root.destroy();
roots.splice(i, 1);
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions packages/ember-glimmer/tests/integration/components/append-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,23 @@ class AbstractAppendTest extends RenderingTest {
this.assert.equal(willDestroyCalled, 1);
}

['@test releasing a root component after it has been destroy'](assert) {
let renderer = this.owner.lookup('renderer:-dom');

this.registerComponent('x-component', {
ComponentClass: Component.extend()
});

this.component = this.owner.factoryFor('component:x-component').create();
this.append(this.component);

assert.equal(renderer._roots.length, 1, 'added a root component');

this.runTask(() => this.component.destroy());

assert.equal(renderer._roots.length, 0, 'released the root component');
}

['@test appending, updating and destroying multiple components'](assert) {
let willDestroyCalled = 0;

Expand Down

0 comments on commit bd60d85

Please sign in to comment.