(_sobj, prop, value)
| 921 | }, |
| 922 | |
| 923 | set(_sobj, prop, value) { |
| 924 | const currentValue = changeTracker.copy_[prop as keyof T] |
| 925 | debugLog( |
| 926 | `set called for property ${String(prop)}, current:`, |
| 927 | currentValue, |
| 928 | `new:`, |
| 929 | value, |
| 930 | ) |
| 931 | |
| 932 | // Only track the change if the value is actually different |
| 933 | if (!deepEquals(currentValue, value)) { |
| 934 | // Check if the new value is equal to the original value |
| 935 | // Important: Use the originalObject to get the true original value |
| 936 | const originalValue = changeTracker.originalObject[prop as keyof T] |
| 937 | const isRevertToOriginal = deepEquals(value, originalValue) |
| 938 | debugLog( |
| 939 | `value:`, |
| 940 | value, |
| 941 | `original:`, |
| 942 | originalValue, |
| 943 | `isRevertToOriginal:`, |
| 944 | isRevertToOriginal, |
| 945 | ) |
| 946 | |
| 947 | if (isRevertToOriginal) { |
| 948 | debugLog(`Reverting property ${String(prop)} to original value`) |
| 949 | // If the value is reverted to its original state, remove it from changes |
| 950 | delete changeTracker.assigned_[prop.toString()] |
| 951 | |
| 952 | // Make sure the copy is updated with the original value |
| 953 | debugLog(`Updating copy with original value for ${String(prop)}`) |
| 954 | changeTracker.copy_[prop as keyof T] = deepClone(originalValue) |
| 955 | |
| 956 | // Check if all properties in this object have been reverted |
| 957 | debugLog(`Checking if all properties reverted`) |
| 958 | const allReverted = checkIfReverted(changeTracker) |
| 959 | debugLog(`All reverted:`, allReverted) |
| 960 | |
| 961 | if (allReverted) { |
| 962 | debugLog(`All properties reverted, clearing tracking`) |
| 963 | // If all have been reverted, clear tracking |
| 964 | changeTracker.modified = false |
| 965 | changeTracker.assigned_ = {} |
| 966 | |
| 967 | // If we're a nested object, check if the parent needs updating |
| 968 | if (parent) { |
| 969 | debugLog(`Updating parent for property:`, parent.prop) |
| 970 | checkParentStatus(parent.tracker, parent.prop) |
| 971 | } |
| 972 | } else { |
| 973 | // Some properties are still changed |
| 974 | debugLog(`Some properties still changed, keeping modified flag`) |
| 975 | changeTracker.modified = true |
| 976 | } |
| 977 | } else { |
| 978 | debugLog(`Setting new value for property ${String(prop)}`) |
| 979 | |
| 980 | // Set the value on the copy |
nothing calls this directly
no test coverage detected