Skip to content

Commit

Permalink
Merge pull request #1886 from gsmeets/fix-component-controller-not-de…
Browse files Browse the repository at this point in the history
…stroyed

fixed regression component control destructor
  • Loading branch information
daffl committed Sep 8, 2015
2 parents 2604df6 + d289a02 commit f49c3f6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions component/component.js
Expand Up @@ -467,6 +467,7 @@ steal("can/util", "can/view/callbacks","can/view/elements.js","can/control", "ca
this._bindings.readyComputes = {};
},
destroy: function() {
can.Control.prototype.destroy.apply( this, arguments );
if(typeof this.options.destroy === 'function') {
this.options.destroy.apply(this, arguments);
}
Expand Down
16 changes: 16 additions & 0 deletions component/component_test.js
Expand Up @@ -1679,5 +1679,21 @@ steal("can", "can/map/define", "can/component", "can/view/stache" ,"can/route",
start();
}, 20);
});

test("components control destroy method is called", function(){
expect(0);
can.Component.extend({
tag: 'comp-control-destroy-test',
template: can.stache('<div>click me</div>'),
events: {
"{document} click" : function () {
ok(true, "click registered");
}
}
});
can.append(can.$("#qunit-fixture"), can.stache("<comp-control-destroy-test></comp-control-destroy-test>")({}));
can.remove(can.$("#qunit-fixture>*"));
can.trigger(can.$(document), 'click');
});
}
});

0 comments on commit f49c3f6

Please sign in to comment.