fix(overlays): fix condition in is-equal-config util and add null guard
This commit is contained in:
parent
eb61cbfed2
commit
b6be7ba482
3 changed files with 18 additions and 1 deletions
5
.changeset/sour-rules-rush.md
Normal file
5
.changeset/sour-rules-rush.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@lion/overlays': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix condition in is-equal-config util and add null guard
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
* @returns {boolean} Whether the configs are equivalent
|
* @returns {boolean} Whether the configs are equivalent
|
||||||
*/
|
*/
|
||||||
export function isEqualConfig(a, b) {
|
export function isEqualConfig(a, b) {
|
||||||
if (typeof a !== 'object' || typeof a !== 'object') {
|
if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {
|
||||||
return a === b;
|
return a === b;
|
||||||
}
|
}
|
||||||
const aProps = Object.keys(a);
|
const aProps = Object.keys(a);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,18 @@ describe('isEqualConfig()', () => {
|
||||||
expect(isEqualConfig(config, config)).eql(true);
|
expect(isEqualConfig(config, config)).eql(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('compares null props', () => {
|
||||||
|
const config = TestConfig();
|
||||||
|
const nullPropConfig = {
|
||||||
|
...config,
|
||||||
|
elementToFocusAfterHide: {
|
||||||
|
nullProp: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
// @ts-ignore
|
||||||
|
expect(isEqualConfig(nullPropConfig, nullPropConfig)).eql(true);
|
||||||
|
});
|
||||||
|
|
||||||
it('compares shallow props', () => {
|
it('compares shallow props', () => {
|
||||||
const config = TestConfig();
|
const config = TestConfig();
|
||||||
expect(isEqualConfig(config, { ...config })).eql(true);
|
expect(isEqualConfig(config, { ...config })).eql(true);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue