Permalink
Browse files

Merge pull request #1682 from gabesmed/master

Bugfix in SortableMixin; sortProperty observers not being correctly removed
  • Loading branch information...
2 parents 49dd221 + 335215b commit 668783a620bc004daa063df72c3d84035be6888a @wycats wycats committed Jan 7, 2013
@@ -138,7 +138,7 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
forEach(sortProperties, function(sortProperty) {
Ember.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
}, this);
- });
+ }, this);
}
return this._super(array, idx, removedCount, addedCount);
@@ -195,6 +195,15 @@ test("don't remove and insert if position didn't change", function() {
ok(!insertItemSortedCalled, "insertItemSorted should not have been called");
});
+test("sortProperties observers removed on content removal", function() {
+ var removedObject = unsortedArray.objectAt(2);
+ equal(Ember.listenersFor(removedObject, 'name:change').length, 1,
+ "Before removal, there should be one listener for sortProperty change.");
+ unsortedArray.replace(2, 1, []);
+ equal(Ember.listenersFor(removedObject, 'name:change').length, 0,
+ "After removal, there should be no listeners for sortProperty change.");
+});
+
module("Ember.Sortable with sortProperties", {
setup: function() {
Ember.run(function() {

0 comments on commit 668783a

Please sign in to comment.