Skip to content

Commit

Permalink
Add cleanup of observers on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanCrotaz committed Aug 25, 2015
1 parent 32f6f23 commit de88b48
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions addon/mixins/csp-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ export default Ember.Mixin.create({
this._refreshBindings();
}),

doCleanup: Ember.on('willDestroyElement', function() {
var observers = this.get('_styleObservers') || {};
// remove all bindings
for(var property in observers) {
if (observers.hasOwnProperty(property)) {
observers[property].stop();
delete observers[property];
}
}
this.set('_styleObservers', {});
}),

_refreshBindings: function() {

var hashCode = function(s){
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-cli-csp-style",
"version": "1.13.9",
"version": "1.13.10",
"description": "",
"directories": {
"doc": "doc",
Expand Down

0 comments on commit de88b48

Please sign in to comment.