@domql/utils 2.31.23 → 2.31.26

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.
@@ -435,10 +435,16 @@ const stringToObject = (str, opts = { verbose: true }) => {
435
435
  };
436
436
  const diffObjects = (original, objToDiff, cache, opts) => {
437
437
  let hasDiff = false;
438
- for (const key in objToDiff) {
438
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(original), ...Object.keys(objToDiff)]);
439
+ for (const key of allKeys) {
439
440
  if (key === "ref") continue;
440
441
  const originalProp = original[key];
441
442
  const objToDiffProp = objToDiff[key];
443
+ if (!(key in objToDiff)) {
444
+ cache[key] = void 0;
445
+ hasDiff = true;
446
+ continue;
447
+ }
442
448
  if ((0, import_types.isObject)(originalProp) && (0, import_types.isObject)(objToDiffProp)) {
443
449
  const nestedDiff = diff(originalProp, objToDiffProp, {}, opts);
444
450
  if (nestedDiff && Object.keys(nestedDiff).length > 0) {
@@ -404,10 +404,16 @@ const stringToObject = (str, opts = { verbose: true }) => {
404
404
  };
405
405
  const diffObjects = (original, objToDiff, cache, opts) => {
406
406
  let hasDiff = false;
407
- for (const key in objToDiff) {
407
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(original), ...Object.keys(objToDiff)]);
408
+ for (const key of allKeys) {
408
409
  if (key === "ref") continue;
409
410
  const originalProp = original[key];
410
411
  const objToDiffProp = objToDiff[key];
412
+ if (!(key in objToDiff)) {
413
+ cache[key] = void 0;
414
+ hasDiff = true;
415
+ continue;
416
+ }
411
417
  if (isObject(originalProp) && isObject(objToDiffProp)) {
412
418
  const nestedDiff = diff(originalProp, objToDiffProp, {}, opts);
413
419
  if (nestedDiff && Object.keys(nestedDiff).length > 0) {
package/object.js CHANGED
@@ -499,12 +499,22 @@ export const stringToObject = (str, opts = { verbose: true }) => {
499
499
  export const diffObjects = (original, objToDiff, cache, opts) => {
500
500
  let hasDiff = false
501
501
 
502
- for (const key in objToDiff) {
502
+ // Use union of keys
503
+ const allKeys = new Set([...Object.keys(original), ...Object.keys(objToDiff)])
504
+
505
+ for (const key of allKeys) {
503
506
  if (key === 'ref') continue
504
507
 
505
508
  const originalProp = original[key]
506
509
  const objToDiffProp = objToDiff[key]
507
510
 
511
+ // Handle deleted keys (missing in objToDiff)
512
+ if (!(key in objToDiff)) {
513
+ cache[key] = undefined
514
+ hasDiff = true
515
+ continue
516
+ }
517
+
508
518
  if (isObject(originalProp) && isObject(objToDiffProp)) {
509
519
  const nestedDiff = diff(originalProp, objToDiffProp, {}, opts)
510
520
  if (nestedDiff && Object.keys(nestedDiff).length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.31.23",
3
+ "version": "2.31.26",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -24,7 +24,7 @@
24
24
  "build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
25
25
  "prepublish": "npm run build; npm run copy:package:cjs"
26
26
  },
27
- "gitHead": "c3e317ebd579c68f00b0cea794458456819b4279",
27
+ "gitHead": "126577d65a218af7e2f66b0a3f9691942ee8b9d2",
28
28
  "devDependencies": {
29
29
  "@babel/core": "^7.27.1"
30
30
  }