Skip to content

Fix deep-merge-lite constructor keys and nested __proto__ - #15

Merged
arnelirobles merged 3 commits into
mainfrom
fix/deep-merge-lite-constructor
Nov 12, 2026
Merged

arnelirobles merged 3 commits into
mainfrom
fix/deep-merge-lite-constructor

Conversation

@arnelirobles

Copy link
Copy Markdown
Contributor

isPlainObject now checks the prototype instead of .constructor, so a source with an own constructor key is merged instead of dropped and nested objects with one are cloned instead of shared with the source. __proto__ is skipped at every level (merge and clone). The old skip of constructor and prototype keys is gone: they are plain data on a plain object and writing them cannot reach Object.prototype, which a test checks.

Not changed, a design decision: merge still reads a trailing object with arrayMerge or customMerge as options, so a data object with those keys as last argument is taken as options.

Tests: packages/deep-merge-lite/src/index.test.ts (new constructor and __proto__ keys block). Fails on main, passes here.

- test: packages/deep-merge-lite/src/index.test.ts
  breaks: packages/deep-merge-lite/src/index.ts "return proto === Object.prototype || proto === null;"
- test: packages/deep-merge-lite/src/index.test.ts
  breaks: packages/deep-merge-lite/src/index.ts "if (key === '__proto__') continue;"

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@arnelirobles
arnelirobles marked this pull request as ready for review November 12, 2026 15:36
@arnelirobles
arnelirobles merged commit 42da174 into main Nov 12, 2026
2 checks passed
@arnelirobles
arnelirobles deleted the fix/deep-merge-lite-constructor branch November 12, 2026 15:36
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.

1 participant