Skip to content

fix: ignore inherited child mapping entries - #940

Open
frostace wants to merge 1 commit into
reactjs:masterfrom
frostace:fix/ignore-inherited-child-keys
Open

frostace wants to merge 1 commit into
reactjs:masterfrom
frostace:fix/ignore-inherited-child-keys

Conversation

@frostace

Copy link
Copy Markdown

An enumerable property containing an object on Object.prototype can be copied into TransitionGroup's child mapping after an update. React then throws Objects are not valid as a React child.

ChildMapping now iterates the mappings' own keys and checks ownership when selecting values and transition state. The merged dictionary uses a null prototype, matching getChildMapping.

Regression coverage includes inherited entries in both inputs, a prototype entry shadowing a previous own entry, and own keys named __proto__, constructor, and hasOwnProperty. A mounted TransitionGroup test adds an enumerable prototype property before adding a child. It restores the original descriptor in finally.

Validation:

  • All six new regression cases fail on the original implementation.
  • yarn testonly --runInBand: 7 suites and 62 tests pass with React 18.
  • yarn lint: ESLint and Prettier pass.
  • yarn build: CJS, ESM, and UMD builds pass.

This branch has not been deployed

No deployments
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