forked from rjsf-team/react-jsonschema-form
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert rjsf-team#4446 due to regression
Fixed rjsf-team#4475 by rolling back rjsf-team#4446 - In `@rjsf/utils` rolled back the changes made by rjsf-team#4446 - Updated the `CHANGELOG.md` accordingly
- Loading branch information
1 parent
615a98c
commit 23cc1e0
Showing
4 changed files
with
17 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
import { createCustomEqual } from 'fast-equals'; | ||
import isEqualWith from 'lodash/isEqualWith'; | ||
|
||
/** Implements a deep equals using the `fast-equals.createCustomEqual` function, providing a customized comparator that assumes all functions are equivalent. | ||
/** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that | ||
* assumes all functions are equivalent. | ||
* | ||
* @param a - The first element to compare | ||
* @param b - The second element to compare | ||
* @returns - True if the `a` and `b` are deeply equal, false otherwise | ||
*/ | ||
const deepEquals = createCustomEqual({ | ||
createCustomConfig: () => ({ | ||
// Assume all functions are equivalent | ||
// see https://github.com/rjsf-team/react-jsonschema-form/issues/255 | ||
// | ||
// Performance improvement: knowing that typeof a === function, so, only needs to check if typeof b === function. | ||
// https://github.com/planttheidea/fast-equals/blob/c633c4e653cacf8fd5cbb309b6841df62322d74c/src/comparator.ts#L99 | ||
areFunctionsEqual(_a, b) { | ||
return typeof b === 'function'; | ||
}, | ||
}), | ||
}); | ||
|
||
export default deepEquals; | ||
export default function deepEquals(a: any, b: any): boolean { | ||
return isEqualWith(a, b, (obj: any, other: any) => { | ||
if (typeof obj === 'function' && typeof other === 'function') { | ||
// Assume all functions are equivalent | ||
// see https://github.com/rjsf-team/react-jsonschema-form/issues/255 | ||
return true; | ||
} | ||
return undefined; // fallback to default isEquals behavior | ||
}); | ||
} |