Skip to content

Commit

Permalink
Destroy components on teardown.
Browse files Browse the repository at this point in the history
Fixes #64.
  • Loading branch information
gordonkristan committed Aug 14, 2014
1 parent 08a9892 commit d38c870
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 5 deletions.
12 changes: 11 additions & 1 deletion dist/amd/module-for-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,21 @@ define(
var view = Ember.run(function(){
var subject = context.subject();
containerView.pushObject(subject);
// TODO: destory this somewhere
containerView.appendTo('#ember-testing');
return subject;
});

var oldTeardown = this.teardown;
this.teardown = function() {
Ember.run(function() {
Ember.tryInvoke(containerView, 'destroy');
});

if (oldTeardown) {
return oldTeardown.apply(this, arguments);
}
};

return view.$();
};

Expand Down
12 changes: 11 additions & 1 deletion dist/cjs/module-for-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,21 @@ exports["default"] = function moduleForComponent(name, description, callbacks) {
var view = Ember.run(function(){
var subject = context.subject();
containerView.pushObject(subject);
// TODO: destory this somewhere
containerView.appendTo('#ember-testing');
return subject;
});

var oldTeardown = this.teardown;
this.teardown = function() {
Ember.run(function() {
Ember.tryInvoke(containerView, 'destroy');
});

if (oldTeardown) {
return oldTeardown.apply(this, arguments);
}
};

return view.$();
};

Expand Down
12 changes: 11 additions & 1 deletion dist/globals/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,21 @@ exports["default"] = function moduleForComponent(name, description, callbacks) {
var view = Ember.run(function(){
var subject = context.subject();
containerView.pushObject(subject);
// TODO: destory this somewhere
containerView.appendTo('#ember-testing');
return subject;
});

var oldTeardown = this.teardown;
this.teardown = function() {
Ember.run(function() {
Ember.tryInvoke(containerView, 'destroy');
});

if (oldTeardown) {
return oldTeardown.apply(this, arguments);
}
};

return view.$();
};

Expand Down
12 changes: 11 additions & 1 deletion dist/named-amd/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,21 @@ define("ember-qunit/module-for-component",
var view = Ember.run(function(){
var subject = context.subject();
containerView.pushObject(subject);
// TODO: destory this somewhere
containerView.appendTo('#ember-testing');
return subject;
});

var oldTeardown = this.teardown;
this.teardown = function() {
Ember.run(function() {
Ember.tryInvoke(containerView, 'destroy');
});

if (oldTeardown) {
return oldTeardown.apply(this, arguments);
}
};

return view.$();
};

Expand Down
12 changes: 11 additions & 1 deletion lib/module-for-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,21 @@ export default function moduleForComponent(name, description, callbacks) {
var view = Ember.run(function(){
var subject = context.subject();
containerView.pushObject(subject);
// TODO: destory this somewhere
containerView.appendTo('#ember-testing');
return subject;
});

var oldTeardown = this.teardown;
this.teardown = function() {
Ember.run(function() {
Ember.tryInvoke(containerView, 'destroy');
});

if (oldTeardown) {
return oldTeardown.apply(this, arguments);
}
};

return view.$();
};

Expand Down

0 comments on commit d38c870

Please sign in to comment.