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

Projects
None yet
2 participants
@ljharb
Copy link
Member

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();

This comment has been minimized.

Copy link
@lelandrichardson

lelandrichardson Feb 16, 2016

Collaborator

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

This comment has been minimized.

Copy link
@ljharb

ljharb Feb 16, 2016

Author Member

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

@ljharb ljharb force-pushed the ljharb/type_null branch from face3d2 to 1e410ff Feb 17, 2016

@lelandrichardson

This comment has been minimized.

Copy link
Collaborator

lelandrichardson commented Feb 18, 2016

LGTM.

lelandrichardson added a commit that referenced this pull request Feb 18, 2016

Merge pull request #196 from airbnb/ljharb/type_null
Ensure that `ShallowWrapper` and `ReactWrapper` handle a null child correctly

@lelandrichardson lelandrichardson merged commit aa947f8 into master Feb 18, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@lelandrichardson lelandrichardson deleted the ljharb/type_null branch Feb 18, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.