Skip to content

Commit 0b50eaa

Browse files
marvinhagemeisterdevelopit
authored andcommitted
Fix jsx renderer double closing elements (#36)
Fixes #34
1 parent 555a65d commit 0b50eaa

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export default function renderToString(vnode, context, opts, inner, isSvgMode) {
197197
}
198198
}
199199

200-
if (opts.jsx || VOID_ELEMENTS.indexOf(nodeName)===-1) {
200+
if (VOID_ELEMENTS.indexOf(nodeName)===-1) {
201201
if (pretty && ~s.indexOf('\n')) s += '\n';
202202
s += `</${nodeName}>`;
203203
}

test/jsx.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe('jsx', () => {
9696
<a b={undefined}>bar</a>
9797
)).to.equal(`<a>bar</a>`);
9898
});
99-
99+
100100
it('should render attributes containing VNodes', () => {
101101
expect(renderJsx(
102102
<a b={<c />}>bar</a>
@@ -176,4 +176,12 @@ describe('jsx', () => {
176176
{ functionNames:false }
177177
)).to.equal('<div onClick={Function}></div>');
178178
});
179+
180+
it('should render self-closing elements', () => {
181+
expect(renderJsx(
182+
<meta charset="utf-8" />
183+
)).to.deep.equal(dedent`
184+
<meta charset="utf-8" />
185+
`);
186+
});
179187
});

0 commit comments

Comments
 (0)