Unexpected behavior when Proxy === undefined
kskkido opened this issue · comments
Great job with the library.
Type-safe alternative to immutable.js was exactly what my team was looking for.
We found iassign to behave consistently until we ran our web app through a compatibility test with ie11.
In ie11, and I suspect other environments that do not natively support Proxy class, we get a peculiar behavior when we try to assign a new key-value pair to our target object.
Input Code
const actual = iassign(
{},
t => t.KEY,
() => 'VALUE'
)
Expected Behavior
actual === { KEY: 'VALUE' }
Actual Behavior
actual === 'VALUE'
Bug Report
I played around with the codebase and found the internal getPropPaths returning different outcomes between environments that support the Proxy class and ones that do not.
getPropPaths(t => t.key, {}) === ['key'] // when Proxy exists
getPropPaths(t => t.key, {}) === [] // when Proxy === undefined
This seems to cause the above Input Code to behave as expected within Proxy supported environments and fail in environments, such as ie11, that do not support the class.
I understand that we can get the expected behavior with overload 2, which may be the intended usage, but I believe the inconsistent behavior is something that can be addressed.
Thanks, will work on it shortly.
Fixed in 2.0.8