-
-
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
Fix ShallowWrapper for array-rendering components #1498
Conversation
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.
Thanks!
Could we also take care of mount
while we're at it?
privateSet(this, NODE, getRootNode(this[RENDERER].getNode())); | ||
privateSet(this, NODES, [this[NODE]]); | ||
this.length = 1; | ||
this.setNodesInternal(getRootNode(this[RENDERER].getNode())); |
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 makes setNodesInternal
a public function; it's important to minimize the publicly observable API. Can this be moved to a module-scoped function?
eabb9b8
to
0c40fe0
Compare
I applied the same module-scoped There are deeper problems associated with achieving full support for array-rendering that I'd rather not get into right now—primarily in that |
0c40fe0
to
608a877
Compare
Hmm. Is there any way inside the React 16 adapter, in findDOMNode, to determine when this bug is happening? Separately, could the adapter keep track of which components returned an array or fragment, and then inside findDOMNode, know to return an array of nodes? |
Sorry, I can't commit time to exploring that. I don't think it's a great idea to do it in this pull request anyway, given that this is nicely self-contained and a strict improvement over what was there before. |
@ljharb is there anything else I can do to get this merged? |
2385783
to
6f7f4fb
Compare
@ljharb Is there a plan to publish this soon? I currently have
|
I'm hoping to get a number of changes in the next release related to fragments/arrays; I'll take a look at publishing soon. |
- [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
The following packages are now released: |
This supports shallow rendering and `.find` of `React.Fragment`. See enzymejs/enzyme#1498
This supports shallow rendering and `.find` of `React.Fragment`. See enzymejs/enzyme#1498
This PR is in support of #1149.
There are two main assumptions that I've fixed:
ReactSixteenAdapter
, flatten and map over the render output if possible, instead of assuming that it is always an elementShallowWrapper
, reuse existing logic to setNODE
andNODES
appropriately when the root node is an array