Skip to content

Commit

Permalink
Model.List must test if Model exist when destroying
Browse files Browse the repository at this point in the history
Test if target exist before splicing it from a Model.List. Otherwise the latest element will be removed.
  • Loading branch information
roissard committed Aug 3, 2012
1 parent 517acce commit 44bc720
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,9 @@ steal('can/util','can/observe', function( can ) {
var self = this;
this.bind('change', function(ev, how){
if(/\w+\.destroyed/.test(how)){
self.splice(self.indexOf(ev.target),1);
if (self.indexOf(ev.target)!=-1) {}
self.splice(self.indexOf(ev.target),1);
}
}
})
}
Expand Down

0 comments on commit 44bc720

Please sign in to comment.