Skip to content

fix: preserve own __proto__ keys in structured selectors - #824

Closed
Marve10s wants to merge 1 commit into
reduxjs:masterfrom
Marve10s:fix/structured-selector-own-keys
Closed

Marve10s wants to merge 1 commit into
reduxjs:masterfrom
Marve10s:fix/structured-selector-own-keys

Conversation

@Marve10s

Copy link
Copy Markdown

createStructuredSelector drops an own computed __proto__ key instead of returning the same keys as its input selectors object. An object or null result also changes the output object's prototype.

The result reducer assigns each key into {}, so this key invokes the inherited setter. Define it as an enumerable, writable, configurable own property while keeping ordinary assignment for other keys and preserving the plain-object result.

Reproduction on 5.3.0:

import { createStructuredSelector } from 'reselect'

const select = createStructuredSelector({
  ['__proto__']: state => state.value
})
const result = select({ value: 17 })
console.log(Object.keys(result))

Before: []. After: ['__proto__'], with an own property value of 17.

@netlify

netlify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for reselect-docs canceled.

Name Link
🔨 Latest commit e3f76d5
🔍 Latest deploy log https://app.netlify.com/projects/reselect-docs/deploys/6ad28c61b8c7247729f219f8

@EskiMojo14

Copy link
Copy Markdown
Contributor

did you encounter this issue in a real app?

@markerikson

Copy link
Copy Markdown
Contributor

I don't think we need to handle this case. We expect to deal with plain data, no proto shenanigans.

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.

3 participants