E527 fix(isPlainObject): return true for objects with nested null prototype by bradvogel · Pull Request #6081 · lodash/lodash · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@bradvogel
Copy link

Objects created via Object.create(Object.create(null)) should be considered plain objects since their prototype chain consists only of null-prototype objects and eventually ends in null, without any custom constructors.

This fix was made in Zod here https://github.com/colinhacks/zod/pull/4574/changes

@bradvogel bradvogel marked this pull request as draft January 11, 2026 18:20
Objects created via Object.create(Object.create(null)) should be
considered plain objects since their prototype chain consists only of
null-prototype objects and eventually ends in null, without any custom
constructors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bradvogel bradvogel force-pushed the fix-isPlainObject-nested-null-prototype branch from 60ac492 to f5a950d Compare January 11, 2026 18:24
@bradvogel
Copy link
Author

Closing since this could result in dangerous false positives.

@bradvogel bradvogel closed this Jan 11, 2026
@ljharb
Copy link
Member
ljharb commented Jan 11, 2026

That doesn't make it a plain object - a plain object is one with no prototype methods whatsoever, meaning, it must inherit directly from null. Every single object's prototype chain terminates in null.

@bradvogel
Copy link
Author

Yup - this was a misunderstanding I had. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0