-
-
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
Incorrect behaviour when statically rendering components returning strings #2098
Comments
What is |
Both The offending lines seem to be this: Reproducing this manually in > const cheerio = require("cheerio");
undefined
> let html = "foo";
undefined
> let wrapper = cheerio.load("")(html); // Test "should contain this string"
undefined
> wrapper
initialize {
options:
{ withDomLvl1: true,
normalizeWhitespace: false,
xml: false,
decodeEntities: true },
_root:
initialize {
'0':
{ type: 'root',
name: 'root',
namespace: 'http://www.w3.org/1999/xhtml',
attribs: {},
'x-attribsNamespace': {},
'x-attribsPrefix': {},
children: [Array],
parent: null,
prev: null,
next: null },
options:
{ withDomLvl1: true,
normalizeWhitespace: false,
xml: false,
decodeEntities: true },
length: 1,
_root: [Circular] },
length: 0,
prevObject:
initialize {
'0':
{ type: 'root',
name: 'root',
namespace: 'http://www.w3.org/1999/xhtml',
attribs: {},
'x-attribsNamespace': {},
'x-attribsPrefix': {},
children: [Array],
parent: null,
prev: null,
next: null },
options:
{ withDomLvl1: true,
normalizeWhitespace: false,
xml: false,
decodeEntities: true },
length: 1,
_root: [Circular] } }
> html = "bar!";
'bar!'
> wrapper = cheerio.load("")(html); // Test "should not break static rendering"
SyntaxError: Unmatched selector: ! Passing > const cheerio = require("cheerio");
undefined
> const html = "bar!";
'bar!'
> const wrapper = cheerio.load(html);
{ [Function: initialize]
fn:
initialize {
constructor: [Circular],
_originalRoot:
{ type: 'root',
name: 'root',
namespace: 'http://www.w3.org/1999/xhtml',
attribs: {},
'x-attribsNamespace': {},
'x-attribsPrefix': {},
children: [Array],
parent: null,
prev: null,
next: null } },
load: [Function],
html: [Function],
xml: [Function],
text: [Function],
parseHTML: [Function],
root: [Function],
contains: [Function],
merge: [Function],
_root:
{ type: 'root',
name: 'root',
namespace: 'http://www.w3.org/1999/xhtml',
attribs: {},
'x-attribsNamespace': {},
'x-attribsPrefix': {},
children: [ [Object] ],
parent: null,
prev: null,
next: null },
_options:
{ withDomLvl1: true,
normalizeWhitespace: false,
xml: false,
decodeEntities: true } }
> wrapper.text()
'bar!' |
Hmm - this seems related to the breaking changes made to adapt to Cheerio v1 in enzyme 3. |
For reference:
|
- Fix enzymejs#2098 - Introduce `loadCheerioRoot` util - Use util in `render`, `mount` and `shallow`
- Fix enzymejs#2098 - Introduce `loadCheerioRoot` util - Use util in `render`, `mount` and `shallow`
- Fix enzymejs#2098 - Introduce `loadCheerioRoot` util - Use util in `render`, `mount` and `shallow`
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- Fix enzymejs#2098 - Introduce `loadCheerioRoot` util - Use util in `render`, `mount` and `shallow`
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
- [enzyme] [fix] `render`: handle Fiber strings and numbers - [enzyme] [new] `Utils`: add `loadCheerioRoot` Fixes enzymejs#2098
Current behavior
Using Enzyme's static
render()
on a component that returns a string returns an empty result or breaks:Setup
Tests
Results
The results are identical when using class components.
Expected behavior
All tests should pass
Your environment
API
Version
Adapter
The text was updated successfully, but these errors were encountered: