Adding Fragment support for shallow .find and .findWhere
#1733
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()inRSTTraversalto 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.renderedin 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
.renderedof 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.