Skip to content

Commit

Permalink
Minor style change of contentLengthDidChange observers
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasbadia committed Jun 16, 2020
1 parent ebd2d59 commit a671c6e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions frameworks/desktop/views/collection.js
Expand Up @@ -895,15 +895,14 @@ SC.CollectionView = SC.View.extend(SC.ActionSupport, SC.CollectionViewDelegate,
- update layout for receiver
*/
_cv_contentDidChange: function() {
var content = this.get('content'),
lfunc = this.contentLengthDidChange ;
var content = this.get('content');

if (content === this._content) return; // nothing to do

// cleanup old content
this.removeContentRangeObserver();
if (this._content) {
this._content.removeObserver('length', this, lfunc);
this._content.removeObserver('length', this, 'contentLengthDidChange');
}

// Destroy all pooled views.
Expand All @@ -920,7 +919,7 @@ SC.CollectionView = SC.View.extend(SC.ActionSupport, SC.CollectionViewDelegate,

// add new observers - range observer will be added lazily
if (content) {
content.addObserver('length', this, lfunc);
content.addObserver('length', this, 'contentLengthDidChange');
}

// notify all items changed
Expand Down Expand Up @@ -975,7 +974,7 @@ SC.CollectionView = SC.View.extend(SC.ActionSupport, SC.CollectionViewDelegate,
length = this.get('length');
if (length > 1 && invalid.max === length) {
invalid.add(length - 2);
}
}
} else {
this._invalidIndexes = YES ; // force a total reload
}
Expand Down Expand Up @@ -3207,7 +3206,7 @@ SC.CollectionView = SC.View.extend(SC.ActionSupport, SC.CollectionViewDelegate,
// All manipulations made to objects we use must be reversed!
var content = this._content;
if (content) {
content.removeObserver('length', this, this.contentLengthDidChange);
content.removeObserver('length', this, 'contentLengthDidChange');

this._content = null;
}
Expand Down

0 comments on commit a671c6e

Please sign in to comment.