Skip to content
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

Ensure that ShallowWrapper and ReactWrapper handle a null child correctly #196

Merged
merged 2 commits into from
Feb 18, 2016

Conversation

ljharb
Copy link
Member

@ljharb ljharb commented Feb 16, 2016

Fixes #52 .

@@ -321,7 +321,7 @@ export default class ShallowWrapper {
* @returns {CheerioWrapper}
*/
render() {
return cheerio.load(this.html()).root();
return this.type() === null ? cheerio() : cheerio.load(this.html()).root();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did the previous implementation of this throw an exception in this case? is cheerio() what we want to return?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, previously it threw TypeError: Cannot read property 'parent' of null from inside cheerio.

cheerio() and cheerio(null) and cheerio('') all return an empty cheerio wrapper - i just chose the simplest of these

@lelandrichardson
Copy link
Collaborator

LGTM.

lelandrichardson added a commit that referenced this pull request Feb 18, 2016
Ensure that `ShallowWrapper` and `ReactWrapper` handle a null child correctly
@lelandrichardson lelandrichardson merged commit aa947f8 into master Feb 18, 2016
@lelandrichardson lelandrichardson deleted the ljharb/type_null branch February 18, 2016 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants