Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change typeof for prototype check to only process plain objects as mappers inputs #4258

Merged
merged 2 commits into from
Mar 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/reanimated2/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ export function createMapperRegistry() {
}
} else if (inputs.addListener) {
resultArray.push(inputs);
} else if (typeof inputs === 'object') {
} else if (inputs.__proto__ === Object.prototype) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __proto__ property seems to be deprecated, maybe could we use Object.getPrototypeOf?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, that's a good suggestion

// we only extract inputs recursively from "plain" objects here, if object
// is of a derivative class (e.g. HostObject on web, or Map) we don't scan
// it recursively
for (const element of Object.values(inputs)) {
element && extractInputs(element, resultArray);
}
Expand Down