slate 0.126.1 → 0.126.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1320,42 +1320,37 @@ var isObject = function isObject(value) {
1320
1320
  return _typeof(value) === 'object' && value !== null;
1321
1321
  };
1322
1322
 
1323
- /*
1324
- Custom deep equal comparison for Slate nodes.
1325
-
1326
- We don't need general purpose deep equality;
1327
- Slate only supports plain values, Arrays, and nested objects.
1328
- Complex values nested inside Arrays are not supported.
1329
-
1330
- Slate objects are designed to be serialised, so
1331
- missing keys are deliberately normalised to undefined.
1323
+ /**
1324
+ * Custom deep equal comparison for Slate nodes. Since Slate only supports plain
1325
+ * values, arrays and nested objects, we don't need a general purpose deep
1326
+ * equality check.
1327
+ *
1328
+ * Slate objects are designed to be serialised, so missing keys are deliberately
1329
+ * normalised to undefined.
1332
1330
  */
1333
- var isDeepEqual = function isDeepEqual(node, another) {
1334
- for (var key in node) {
1335
- var a = Object.hasOwn(node, key) ? node[key] : undefined;
1336
- var b = Object.hasOwn(another, key) ? another[key] : undefined;
1337
- if (Array.isArray(a) && Array.isArray(b)) {
1338
- if (a.length !== b.length) return false;
1339
- for (var i = 0; i < a.length; i++) {
1340
- if (a[i] !== b[i]) return false;
1341
- }
1342
- } else if (isObject(a) && isObject(b)) {
1343
- if (!isDeepEqual(a, b)) return false;
1344
- } else if (a !== b) {
1345
- return false;
1331
+ var isDeepEqual = function isDeepEqual(a, b) {
1332
+ if (Array.isArray(a) && Array.isArray(b)) {
1333
+ if (a.length !== b.length) return false;
1334
+ for (var i = 0; i < a.length; i++) {
1335
+ if (!isDeepEqual(a[i], b[i])) return false;
1346
1336
  }
1337
+ return true;
1347
1338
  }
1348
- /*
1349
- Deep object equality is only necessary in one direction; in the reverse direction
1350
- we are only looking for keys that are missing.
1351
- As above, undefined keys are normalised to missing.
1352
- */
1353
- for (var _key in another) {
1354
- if (node[_key] === undefined && another[_key] !== undefined) {
1355
- return false;
1339
+ if (isObject(a) && isObject(b)) {
1340
+ for (var key in a) {
1341
+ var valueA = Object.hasOwn(a, key) ? a[key] : undefined;
1342
+ var valueB = Object.hasOwn(b, key) ? b[key] : undefined;
1343
+ if (!isDeepEqual(valueA, valueB)) return false;
1344
+ }
1345
+ // Deep object equality is only necessary in one direction; in the reverse
1346
+ // direction we are only looking for keys that are missing. As above,
1347
+ // undefined keys treated the same as missing keys.
1348
+ for (var _key in b) {
1349
+ if (a[_key] === undefined && b[_key] !== undefined) return false;
1356
1350
  }
1351
+ return true;
1357
1352
  }
1358
- return true;
1353
+ return a === b;
1359
1354
  };
1360
1355
 
1361
1356
  /**