Skip to content

Commit

Permalink
[BUGFIX] Ensure @sort works on non-Ember.Objects.
Browse files Browse the repository at this point in the history
Assuming that `this.notifyPropertyChange` is a method on the object that
the `sort` is operating on is not a safe assumption. Specifically, when
operating on a `@glimmer/component` (which is _essentially_ just a very
very basic native class) there is no `notifyPropertyChange` method and
an error was thrown.
  • Loading branch information
rwjblue committed Apr 2, 2019
1 parent ed3b0a3 commit 00a0c0b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/@ember/object/lib/computed/reduce_computed_macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
*/
import { DEBUG } from '@glimmer/env';
import { assert } from '@ember/debug';
import { get, computed, addObserver, removeObserver } from '@ember/-internals/metal';
import {
get,
computed,
addObserver,
removeObserver,
notifyPropertyChange,
} from '@ember/-internals/metal';
import { compare, isArray, A as emberA, uniqBy as uniqByArray } from '@ember/-internals/runtime';

function reduceMacro(dependentKey, callback, initialValue, name) {
Expand Down Expand Up @@ -1427,7 +1433,7 @@ function propertySort(itemsKey, sortPropertiesKey) {

if (!sortPropertyDidChangeMap.has(this)) {
sortPropertyDidChangeMap.set(this, function() {
this.notifyPropertyChange(key);
notifyPropertyChange(this, key);
});
}

Expand Down

0 comments on commit 00a0c0b

Please sign in to comment.