You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The diff function exhibits inconsistent behavior when comparing changes between properties of different Object-derived types such as Array, Set, Map, etc. It appears to misidentify certain type changes as property additions/removals rather than recognizing a complete change in the property's type.
When the diff function encounters property values that have changed type—specifically from an Array, Set, Map, Error, Promise, or Proxy to another object type—it incorrectly reports the changes as individual property mutations (CREATE and REMOVE) rather than recognizing a CHANGE in the entire value for the key.
For types such as Function, Date, and RegExp, when these are nested property values, the change is correctly detected as a CHANGE. However, when types like Array, Set, or Map are nested, they do not receive the same treatment.
Additional Context:
There's a discrepancy based on whether the Object-derived types are passed directly as an argument to diff or nested. For example:
Microdiff expects a top-level object, and certain object derived types like Date are interpreted as opaque by microdiff (they are diffed like primitives). This is intended behavior, and is what causes the discrepancy for top-level object derived types.
The first issue is unintended though. I will work on a fix.
Issue Summary:
The
diff
function exhibits inconsistent behavior when comparing changes between properties of different Object-derived types such as Array, Set, Map, etc. It appears to misidentify certain type changes as property additions/removals rather than recognizing a complete change in the property's type.Example:
Description of the bug:
When the
diff
function encounters property values that have changed type—specifically from an Array, Set, Map, Error, Promise, or Proxy to another object type—it incorrectly reports the changes as individual property mutations (CREATE
andREMOVE
) rather than recognizing aCHANGE
in the entire value for the key.For types such as Function, Date, and RegExp, when these are nested property values, the change is correctly detected as a
CHANGE
. However, when types like Array, Set, or Map are nested, they do not receive the same treatment.Additional Context:
There's a discrepancy based on whether the Object-derived types are passed directly as an argument to diff or nested. For example:
It is not clear if this behavior is intentional or an oversight. Clarification in the documentation would be beneficial.
The text was updated successfully, but these errors were encountered: