Throw when mount/shallow rendering invalid root elements#1759
Merged
ljharb merged 1 commit intoenzymejs:masterfrom Aug 18, 2018
Merged
Throw when mount/shallow rendering invalid root elements#1759ljharb merged 1 commit intoenzymejs:masterfrom
ljharb merged 1 commit intoenzymejs:masterfrom
Conversation
0856e7f to
b3d34b4
Compare
ljharb
requested changes
Aug 17, 2018
Member
ljharb
left a comment
There was a problem hiding this comment.
This will actually need a rebase
|
|
||
| if (!root) { | ||
| const adapter = getAdapter(options); | ||
| if (!adapter.isValidElement(nodes)) { |
Member
There was a problem hiding this comment.
hmm, nodes could be an array of valid elements; i'm not sure we can check it directly.
also, i think we probably want to check this on root too if that's provided?
Collaborator
Author
There was a problem hiding this comment.
I think if we try to mount an array of elements as the root that should still throw.
root elements should always have already been through this path when they were created, ie wrap/ReactWrapper constructor only get called with null when mounting (or diving in the shallow wrapper) or this[ROOT] when traversing, which is only set here.
473c67e to
4324666
Compare
Collaborator
Author
|
The tests added failed previously with for the mount tests and for the shallow tests |
4324666 to
997f95a
Compare
ljharb
approved these changes
Aug 17, 2018
ljharb
added a commit
that referenced
this pull request
Aug 25, 2018
- [New] Add forwardRef support (#1592, @jquense) - [New] Add Portal support (#1760, #1761, #1772, #1774, @jgzuke) - [New] Add pointer events support (#1753, @ljharb) - [Fix] preemptively fix compat with React v16.4.3 (#1790, #1778, @gaearon, @aweary) - [Fix] `shallow`: prevent rerenders with PureComponents (#1786, @koba04) - [Fix] `shallow`: skip updates when nextState is `null` or `undefined` (#1785, @koba04) - [Fix] `shallow`: `setState` after `setProps` calls `componentWillReceiveProps` (#1779, @peanutenthusiast) - [Fix] `mount`/`shallow`: be stricter on the wrapper’s setState/setProps callback - [Fix] `shallow`/`mount`: improve error message when wrapping invalid elements (#1759, @jgzuke) - update deps - [Refactor] remove most uses of lodash - [meta] ensure a license and readme is present in all packages when published
This was referenced Aug 25, 2018
This was referenced Oct 1, 2018
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.
Throw
TypeError('ShallowWrapper can only wrap valid elements')orTypeError('ReactWrapper can only wrap valid elements')whenShallowWrapperorReactWrapperare created wrapping an invalid element as root.