Allow empty strings as key props#1524
Merged
ljharb merged 1 commit intoenzymejs:masterfrom Feb 23, 2018
Merged
Conversation
10 tasks
bdwain
approved these changes
Feb 11, 2018
tryggvigy
commented
Feb 11, 2018
| } | ||
|
|
||
| export function ensureKeyOrUndefined(key) { | ||
| return key || (key === '' ? '' : undefined); |
Author
There was a problem hiding this comment.
This check could be more restrictive.
export function ensureStringOrUndefined(key) {
return typeof key === 'string' ? key : undefined;
}Are there situations where a key can be anything other than a string or a falsey value?
Contributor
There was a problem hiding this comment.
react stringifies all valid keys before storing them, and a key is valid if it is not undefined. So i think this workes either way. I think it's probably best to leave it as you have now
Member
There was a problem hiding this comment.
maybe typeof key === 'string' ? key : undefined?
ljharb
approved these changes
Feb 23, 2018
| } | ||
|
|
||
| export function ensureKeyOrUndefined(key) { | ||
| return key || (key === '' ? '' : undefined); |
Member
There was a problem hiding this comment.
maybe typeof key === 'string' ? key : undefined?
8ffd0f1 to
f080dc9
Compare
ljharb
added a commit
that referenced
this pull request
Jul 9, 2018
- [New] Add event name mapping for animation events - [Fix] Allow empty strings as key props (#1524) - [Deps] remove unneeded `lodash` dep, update `object.assign` - [Dev Deps] update `babel-cli`, `babel-core`, `babel-plugin-transform-replace-object-assign`, `babel-preset-airbnb`, `chai`, `coveralls`, `eslint`, `eslint-config-airbnb`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `json-loader`, `lerna`, `karma-firefox-launcher`, `prop-types`, `lerna`, `rimraf`, `webpack`
ljharb
added a commit
that referenced
this pull request
Jul 9, 2018
- [fix] call ref for a root element (#1541) - [fix] Allow empty strings as key props (#1524) - [fix] Allow empty strings as key props - [fix] correct the adapter class name - [fix] `mount`: make sure it works with native arrow functions (#1667) - [refactor]: add “lifecycles” adapter option (#1696) - [refactor] use `react-is` package - [deps] remove unneeded `lodash` dep; update `prop-types`, `enzyme-adapter-utils`, `object.assign` - [dev deps] update `babel-cli`, `babel-core`, `babel-plugin-transform-replace-object-assign`, `babel-preset-airbnb`, `chai`, `coveralls`, `eslint`, `eslint-config-airbnb`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `lerna`, `json-loader`, `karma-firefox-launcher`, `prop-types`, `lerna`, `rimraf`, `webpack`
ljharb
added a commit
that referenced
this pull request
Jul 9, 2018
- [fix] actually invoke the setState callback (#1465, #1453) - [fix] add missing support for animation events (#1569) - [fix] call ref for a root element (#1541) - [fix] Allow empty strings as key props (#1524) - [fix] correct the adapter class name - [fix] `mount`: make sure it works with native arrow functions (#1667) - [refactor]: add “lifecycles” adapter option (#1696) - [refactor] use `react-is` package - [deps] remove unneeded `lodash` dep; update `prop-types`, `enzyme-adapter-utils`, `object.assign` - [dev deps] update `babel-cli`, `babel-core`, `babel-plugin-transform-replace-object-assign`, `babel-preset-airbnb`, `chai`, `coveralls`, `eslint`, `eslint-config-airbnb`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `lerna`, `json-loader`, `karma-firefox-launcher`, `prop-types`, `lerna`, `rimraf`, `webpack`
ljharb
added a commit
that referenced
this pull request
Jul 9, 2018
- [fix] actually invoke the setState callback (#1465, #1453) - [fix] add missing support for animation events (#1569) - [fix] call ref for a root element (#1541) - [fix] Allow empty strings as key props (#1524) - [fix] correct the adapter class name - [fix] `mount`: make sure it works with native arrow functions (#1667) - [refactor]: add “lifecycles” adapter option (#1696) - [refactor] use `react-is` package - [deps] remove unneeded `lodash` dep; update `prop-types`, `enzyme-adapter-utils`, `object.assign` - [dev deps] update `babel-cli`, `babel-core`, `babel-plugin-transform-replace-object-assign`, `babel-preset-airbnb`, `chai`, `coveralls`, `eslint`, `eslint-config-airbnb`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `lerna`, `json-loader`, `karma-firefox-launcher`, `prop-types`, `lerna`, `rimraf`, `webpack`
ljharb
added a commit
that referenced
this pull request
Aug 8, 2018
- [new] add `isFragment` (#1733) - [new] Add `displayNameOfNode`, `isValidElementType` - [new] `mount`: add `hydrateIn` option (#1317, #1707) - [new] Add support for react context element types (#1513) - [new] `shallow`: Add getSnapshotBeforeUpdate support (#1657) - [fix] portals and roots may render fragments (#1733) - [fix] add missing support for animation events (#1569) - [fix] `shallow`: SFCs do not get a `this` (#1703) - [refactor]: add “lifecycles” adapter option (#1696) - [fix] call ref for a root element (#1541) - [fix] Allow empty strings as key props (#1524) - [fix] Fix ShallowWrapper for array-rendering components (#1498) - [refactor] use `react-is` package - [meta] ensure a license and readme is present in all packages when published
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR will
Why?
React allows empty string key props. We should too: