Skip to content

Commit c20f222

Browse files
test(html-to-react): add test for option htmlparser2
1 parent c4ecf64 commit c20f222

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/html-to-react.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,20 @@ describe('HTML to React', () => {
137137
assert.deepEqual(preactElement, Preact.createElement('p', {}, 'foo'));
138138
});
139139
});
140+
141+
describe('htmlparser2', () => {
142+
it('parses XHTML with xmlMode enabled', () => {
143+
// using self-closing syntax (`/>`) for non-void elements is invalid
144+
// which causes elements to nest instead of being rendered correctly
145+
// enabling htmlparser2 option xmlMode resolves this issue
146+
const html = '<ul><li/><li/></ul>';
147+
const options = { htmlparser2: { xmlMode: true } };
148+
const reactElements = parse(html, options);
149+
assert.strictEqual(
150+
render(reactElements),
151+
'<ul><li></li><li></li></ul>'
152+
);
153+
});
154+
});
140155
});
141156
});

0 commit comments

Comments
 (0)