@mintjamsinc/ichigojs 0.1.52 → 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 -6
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +32 -6
- 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 -6
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/ichigo.esm.js
CHANGED
|
@@ -7885,7 +7885,7 @@ class ReactiveProxy {
|
|
|
7885
7885
|
}
|
|
7886
7886
|
// Create the proxy with path captured in closure
|
|
7887
7887
|
const proxy = new Proxy(target, {
|
|
7888
|
-
get(obj, key) {
|
|
7888
|
+
get(obj, key, receiver) {
|
|
7889
7889
|
const value = Reflect.get(obj, key);
|
|
7890
7890
|
// If the value is an object or array, make it reactive too
|
|
7891
7891
|
if (typeof value === 'object' && value !== null) {
|
|
@@ -7904,16 +7904,42 @@ class ReactiveProxy {
|
|
|
7904
7904
|
const nestedPath = path ? (Array.isArray(obj) ? `${path}[${keyStr}]` : `${path}.${keyStr}`) : keyStr;
|
|
7905
7905
|
return ReactiveProxy.create(value, onChange, nestedPath);
|
|
7906
7906
|
}
|
|
7907
|
-
//
|
|
7908
|
-
if (
|
|
7909
|
-
|
|
7910
|
-
if (
|
|
7907
|
+
// If the value is a function, we need to wrap it to ensure that any mutations it performs also trigger onChange
|
|
7908
|
+
if (typeof value === 'function') {
|
|
7909
|
+
// For arrays, we only want to wrap mutation methods, not read methods like 'slice', 'concat', etc.
|
|
7910
|
+
if (Array.isArray(obj)) {
|
|
7911
|
+
const arrayMutationMethods = ['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'];
|
|
7912
|
+
if (!arrayMutationMethods.includes(key)) {
|
|
7913
|
+
return value;
|
|
7914
|
+
}
|
|
7911
7915
|
return function (...args) {
|
|
7912
|
-
const result = value.apply(obj, args);
|
|
7916
|
+
const result = value.apply(this === receiver ? obj : this, args);
|
|
7913
7917
|
onChange(path || undefined);
|
|
7914
7918
|
return result;
|
|
7915
7919
|
};
|
|
7916
7920
|
}
|
|
7921
|
+
// For Map, we only want to wrap mutation methods, not read methods like 'get' or 'has'
|
|
7922
|
+
if (obj.constructor.name === 'Map') {
|
|
7923
|
+
const mapMutationMethods = ['set', 'delete', 'clear'];
|
|
7924
|
+
return function (...args) {
|
|
7925
|
+
const result = value.apply(this === receiver ? obj : this, args);
|
|
7926
|
+
if (mapMutationMethods.includes(key)) {
|
|
7927
|
+
onChange(path || undefined);
|
|
7928
|
+
}
|
|
7929
|
+
return result;
|
|
7930
|
+
};
|
|
7931
|
+
}
|
|
7932
|
+
// For Set, we only want to wrap mutation methods, not read methods like 'has'
|
|
7933
|
+
if (obj.constructor.name === 'Set') {
|
|
7934
|
+
const setMutationMethods = ['add', 'delete', 'clear'];
|
|
7935
|
+
return function (...args) {
|
|
7936
|
+
const result = value.apply(this === receiver ? obj : this, args);
|
|
7937
|
+
if (setMutationMethods.includes(key)) {
|
|
7938
|
+
onChange(path || undefined);
|
|
7939
|
+
}
|
|
7940
|
+
return result;
|
|
7941
|
+
};
|
|
7942
|
+
}
|
|
7917
7943
|
}
|
|
7918
7944
|
return value;
|
|
7919
7945
|
},
|