Use Object.create(null) over {} to avoid prototype issues - v16#4631
Merged
Use Object.create(null) over {} to avoid prototype issues - v16#4631
Object.create(null) over {} to avoid prototype issues - v16#4631Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
327c70b to
fef1792
Compare
benjie
added a commit
that referenced
this pull request
Mar 24, 2026
## v16.13.2 (2026-03-24) #### Docs 📝 * [#4611](#4611) add dev mode docs ([@yaacovCR](https://github.com/yaacovCR)) #### Polish 💅 * [#4631](#4631) Use `Object.create(null)` over `{}` to avoid prototype issues - v16 ([@benjie](https://github.com/benjie)) #### Internal 🏠 * [#4626](#4626) backport: internal: streamline release process (#4615) ([@yaacovCR](https://github.com/yaacovCR)) #### Committers: 2 * Benjie([@benjie](https://github.com/benjie)) * Yaacov Rydzinski ([@yaacovCR](https://github.com/yaacovCR))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Object.create(null)is generally safer since it is not vulnerable to prototype pollution in user code. To avoid breaking changes I've returned{ ...obj }thus ensuring that the returned object still has the default Object prototype. An alternative would beObject.setPrototypeOf(obj, Object.prototype), but that messes with hidden classes so I figured this solution is cleaner even though it's an additional object allocation. I've also tidied up the variables orphaned by #4453