Skip to content

Commit

Permalink
Use .toJSON in abstractDeepEqual as well (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed Jul 16, 2021
1 parent 2f9f39d commit caeeb6d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions frontend/src/utilities/abstractDeepEqual.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { keys, every, isObject, isFunction, isNumber } from 'lodash';
import { Model, Collection } from 'backbone';

/**
* Recursively compare the contents of two nested data structures.
Expand Down Expand Up @@ -37,11 +36,8 @@ export default function abstractDeepEqual(left: any, right: any): boolean {
}
}
// the Backbone-aware part: ignore everything except for the content
if (left instanceof Model) {
return abstractDeepEqual(left['attributes'], right['attributes']);
}
if (left instanceof Collection) {
return abstractDeepEqual(left['models'], right['models']);
if (isFunction(left['toJSON'])) {
return abstractDeepEqual(left['toJSON'](), right['toJSON']());
}
// We end up iterating both values either as plain arrays or plain objects.
// We want to avoid a situation where one is iterated as array while the
Expand Down

0 comments on commit caeeb6d

Please sign in to comment.