Commit 4e0b923
Fix prototype check in AnimatedObject.js (#54820)
Summary:
`isPlainObject` function defined in `AnimatedObject.js` doesn't handle `Object.create(null)` correctly.
this will throws when encountering objects with null prototype:
```js
Object.getPrototypeOf(Object.create(null)).isPrototypeOf(Object)
// TypeError: Cannot read properties of null (reading 'isPrototypeOf')
```
This breaks compatibility with libraries that use `Object.create(null)` for creating clean dictionary objects.
## Changelog:
[GENERAL] [FIXED] - Handle `Object.create(null)` correctly in AnimatedObject.js' `isPlainObject` function
Pull Request resolved: #54820
Test Plan:
```
import { isPlainObject } from 'react-native/Libraries/Animated/nodes/AnimatedObject';
// Before: throws TypeError
// After: returns true
isPlainObject(Object.create(null));
// Existing behavior unchanged
isPlainObject({}); // true
isPlainObject([]); // false
isPlainObject(null); // false
isPlainObject(new Date()); // false
```
Reviewed By: zeyap
Differential Revision: D88754908
Pulled By: javache
fbshipit-source-id: ea48908493b72da67699e48b35a6dc7e6714006d1 parent f9346fb commit 4e0b923
1 file changed
Lines changed: 9 additions & 4 deletions
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
27 | 35 | | |
28 | 36 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 37 | + | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| |||
0 commit comments