Description
The React Native structuredClone polyfill reconstructs Number, String, Boolean, and Date wrappers by passing the source object to a constructor. Number/String cloning invokes user coercion hooks, and new Boolean(new Boolean(false)) uses object truthiness and silently changes the internal value to true.
Expected behavior
Cloning should read each wrapper's internal primitive through the built-in valueOf intrinsic, create a distinct wrapper with the same value, and never execute user coercion. Native structuredClone follows this behavior.
React Native Version
0.87.1 and current main
Affected Platforms
JavaScript runtime - All
Description
The React Native
structuredClonepolyfill reconstructs Number, String, Boolean, and Date wrappers by passing the source object to a constructor. Number/String cloning invokes user coercion hooks, andnew Boolean(new Boolean(false))uses object truthiness and silently changes the internal value to true.Expected behavior
Cloning should read each wrapper's internal primitive through the built-in
valueOfintrinsic, create a distinct wrapper with the same value, and never execute user coercion. NativestructuredClonefollows this behavior.React Native Version
0.87.1 and current main
Affected Platforms
JavaScript runtime - All