Description
The React Native structuredClone polyfill initializes an array clone as [] and only assigns enumerable keys. If a sparse array's highest populated index precedes its declared length, the trailing holes are lost and the clone is silently shortened. For example, new Array(3) with only index 1 populated becomes length 2.
Expected behavior
The clone should preserve the source array's declared length and holes. Node's native structuredClone follows this behavior.
React Native Version
0.87.1 and current main
Affected Platforms
JavaScript runtime - All
Description
The React Native
structuredClonepolyfill initializes an array clone as[]and only assigns enumerable keys. If a sparse array's highest populated index precedes its declared length, the trailing holes are lost and the clone is silently shortened. For example,new Array(3)with only index 1 populated becomes length 2.Expected behavior
The clone should preserve the source array's declared length and holes. Node's native
structuredClonefollows this behavior.React Native Version
0.87.1 and current main
Affected Platforms
JavaScript runtime - All