-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Adding Fragment support for shallow .find
and .findWhere
#1733
Merged
Conversation
This file contains 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
ljharb
force-pushed
the
mac--support-for-fragments-in-shallow
branch
from
August 5, 2018 05:59
3280135
to
54498a0
Compare
ljharb
approved these changes
Aug 5, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is excellent, thank you!
ljharb
added
API: shallow
API: mount
semver: minor
New stuff.
package: react adapter: 16
labels
Aug 5, 2018
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 was referenced Aug 8, 2018
evanpurkhiser
added a commit
to getsentry/sentry
that referenced
this pull request
Aug 28, 2018
Fragment's disappearing (or being renamed) is likely due to enzymejs/enzyme#1733
evanpurkhiser
added a commit
to getsentry/sentry
that referenced
this pull request
Aug 28, 2018
Fragment's disappearing (or being renamed) is likely due to enzymejs/enzyme#1733
This was referenced Oct 1, 2018
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 fixes #1664 by altering
childrenOfNode()
inRSTTraversal
to return (recursively if needed to accommodate nesting) the children of any node it encounters that is a Fragment instead of the Fragment element. It additionally updatesmatchAdjacentSiblings()
andmatchGeneralSibling()
to make use ofchildrenOfNode()
instead of looking directly atparent.rendered
in order to make use of the new Fragment logic, which lives inside of theReactSixteenAdapter
'sisFragment()
Consider the following example
Calling
const wrapper = mount(<FragmentExample />);
will yield a wrapper with the following structure:and direct selectors like
wrapper.find('.container > span')
will behave as expected to find the span.If we instead say
const wrapper = shallow(<FragmentExample />)
, however, the wrapper has additional layers in the form of<Symbol(React.fragment)>
:These additional layers caused direct selectors to fail, since simply looking at the
.rendered
of the container div would show the symbol type node, and not a span, as expected.Please let me know if I need any additional tests.