Skip to content

Commit 39030e7

Browse files
samcconeljharb
authored andcommitted
Remove dequal as a dep from the project.
Inspection of the code and types showed that the actual check does not need to handle all cases, but rather there is a small handful of attributes and cases to check. As such do it in the project and remove the entire need for a dep. Ref: #354
1 parent 3f4caed commit 39030e7

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

flow/dequal.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

package-lock.json

Lines changed: 1 addition & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,5 @@
6464
"ie 11"
6565
],
6666
"dependencies": {
67-
"dequal": "^2.0.3"
6867
}
6968
}

src/elementAXObjectMap.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* @flow
33
*/
44

5-
import { dequal } from 'dequal/lite';
65
import AXObjects from './AXObjectsMap';
76
import iterationDecorator from './util/iterationDecorator';
87

@@ -48,6 +47,32 @@ for (let [name, def] of AXObjects.entries()) {
4847
}
4948
}
5049

50+
function deepAxObjectModelRelationshipConceptAttributeCheck(a?: Array<AXObjectModelRelationConceptAttribute>, b?: Array<AXObjectModelRelationConceptAttribute>) {
51+
if (a === undefined && b !== undefined) {
52+
return false;
53+
}
54+
55+
if (a !== undefined && b === undefined) {
56+
return false;
57+
}
58+
59+
if (a !== undefined && b !== undefined) {
60+
if (a.length != b.length) {
61+
return false;
62+
}
63+
64+
// dequal checks position equality
65+
// https://github.com/lukeed/dequal/blob/5ecd990c4c055c4658c64b4bdfc170f219604eea/src/index.js#L17-L22
66+
for (let i = 0; i < a.length; i++) {
67+
if (b[i].name !== a[i].name || b[i].value !== a[i].value) {
68+
return false;
69+
}
70+
}
71+
}
72+
73+
return true;
74+
}
75+
5176
const elementAXObjectMap: TAXObjectQueryMap<
5277
TElementAXObjects,
5378
AXObjectModelRelationConcept,
@@ -66,7 +91,7 @@ const elementAXObjectMap: TAXObjectQueryMap<
6691
},
6792
get: function (key: AXObjectModelRelationConcept): ?Array<AXObjectName> {
6893
const item = elementAXObjects.find(tuple => (
69-
key.name === tuple[0].name && dequal(key.attributes, tuple[0].attributes)
94+
key.name === tuple[0].name && deepAxObjectModelRelationshipConceptAttributeCheck(key.attributes, tuple[0].attributes)
7095
));
7196
return item && item[1];
7297
},

0 commit comments

Comments
 (0)