@mintjamsinc/ichigojs 0.1.53 → 0.1.54
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/ichigo.cjs +32 -12
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +32 -12
- package/dist/ichigo.esm.js.map +1 -1
- package/dist/ichigo.esm.min.js +1 -1
- package/dist/ichigo.min.cjs +1 -1
- package/dist/ichigo.umd.js +32 -12
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/ichigo.cjs
CHANGED
|
@@ -7910,22 +7910,42 @@
|
|
|
7910
7910
|
const nestedPath = path ? (Array.isArray(obj) ? `${path}[${keyStr}]` : `${path}.${keyStr}`) : keyStr;
|
|
7911
7911
|
return ReactiveProxy.create(value, onChange, nestedPath);
|
|
7912
7912
|
}
|
|
7913
|
-
//
|
|
7913
|
+
// If the value is a function, we need to wrap it to ensure that any mutations it performs also trigger onChange
|
|
7914
7914
|
if (typeof value === 'function') {
|
|
7915
|
-
|
|
7915
|
+
// For arrays, we only want to wrap mutation methods, not read methods like 'slice', 'concat', etc.
|
|
7916
7916
|
if (Array.isArray(obj)) {
|
|
7917
|
-
|
|
7917
|
+
const arrayMutationMethods = ['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'];
|
|
7918
|
+
if (!arrayMutationMethods.includes(key)) {
|
|
7919
|
+
return value;
|
|
7920
|
+
}
|
|
7921
|
+
return function (...args) {
|
|
7922
|
+
const result = value.apply(this === receiver ? obj : this, args);
|
|
7923
|
+
onChange(path || undefined);
|
|
7924
|
+
return result;
|
|
7925
|
+
};
|
|
7918
7926
|
}
|
|
7919
|
-
|
|
7920
|
-
|
|
7927
|
+
// For Map, we only want to wrap mutation methods, not read methods like 'get' or 'has'
|
|
7928
|
+
if (obj.constructor.name === 'Map') {
|
|
7929
|
+
const mapMutationMethods = ['set', 'delete', 'clear'];
|
|
7930
|
+
return function (...args) {
|
|
7931
|
+
const result = value.apply(this === receiver ? obj : this, args);
|
|
7932
|
+
if (mapMutationMethods.includes(key)) {
|
|
7933
|
+
onChange(path || undefined);
|
|
7934
|
+
}
|
|
7935
|
+
return result;
|
|
7936
|
+
};
|
|
7937
|
+
}
|
|
7938
|
+
// For Set, we only want to wrap mutation methods, not read methods like 'has'
|
|
7939
|
+
if (obj.constructor.name === 'Set') {
|
|
7940
|
+
const setMutationMethods = ['add', 'delete', 'clear'];
|
|
7941
|
+
return function (...args) {
|
|
7942
|
+
const result = value.apply(this === receiver ? obj : this, args);
|
|
7943
|
+
if (setMutationMethods.includes(key)) {
|
|
7944
|
+
onChange(path || undefined);
|
|
7945
|
+
}
|
|
7946
|
+
return result;
|
|
7947
|
+
};
|
|
7921
7948
|
}
|
|
7922
|
-
return function (...args) {
|
|
7923
|
-
const result = value.apply(this === receiver ? obj : this, args);
|
|
7924
|
-
if (mutationMethods.includes(key)) {
|
|
7925
|
-
onChange(path || undefined);
|
|
7926
|
-
}
|
|
7927
|
-
return result;
|
|
7928
|
-
};
|
|
7929
7949
|
}
|
|
7930
7950
|
return value;
|
|
7931
7951
|
},
|