Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unset keys when concatenating child elements #640

Closed
wants to merge 1 commit into from

Conversation

aduth
Copy link
Member

@aduth aduth commented May 3, 2017

This pull request seeks to modify the behavior of wp.element.concatChildren to unset keys instead of defining new keys by indices within the children and sets of children. Originally these keys were assigned to avoid conflict when a child shared the same key across the sets of children. The problem with this approach is that by only using the array indices, React may try to reconcile two elements from different sets of children that are not truly the same, but merely share the same index (e.g. key 0,0). Instead, we could either ensure a unique key every time we concatenate (via Lodash's uniqueId) or as proposed here, simply unset the key. I had worried this might have produced a React warning recommending that keys be assigned, but in my testing, this does not appear to be the case.

Testing instructions:

Ensure tests pass:

npm test

Verify that there is no regression in the behavior of merging text or heading blocks, and that in doing so, no warnings or errors are logged to your browser developer tools console.

@aduth aduth requested a review from youknowriad May 3, 2017 21:29
@mtias mtias added the Framework Issues related to broader framework topics, especially as it relates to javascript label May 4, 2017
@aduth
Copy link
Member Author

aduth commented May 5, 2017

This is slated to be made obsolete by the removal of concatChildren in #689

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues related to broader framework topics, especially as it relates to javascript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants