Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/gentle-trains-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'preact-render-to-string': major
---

Remove trailing space for void_elements, this could fail some test_assertions as
`<img />` will become `<img/>`, the other `VOID_ELEMENTS` this will be applied for
can be found [here](https://github.com/preactjs/preact-render-to-string/blob/remove-trailing-space/src/index.js#L368-L385)
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {

// Emit self-closing tag for empty void elements:
if (!html && SELF_CLOSING.has(type)) {
return s + ' />';
return s + '/>';
}

return s + '>' + html + '</' + type + '>';
Expand Down
4 changes: 2 additions & 2 deletions test/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('render', () => {

it('should serialize defaultChecked prop to the checked attribute', () => {
let rendered = render(<input type="checkbox" defaultChecked />),
expected = `<input type="checkbox" checked />`;
expected = `<input type="checkbox" checked/>`;

expect(rendered).to.equal(expected);
});
Expand Down Expand Up @@ -240,7 +240,7 @@ describe('render', () => {
<wbr />
</div>
),
expected = `<div><input type="text" /><wbr /></div>`;
expected = `<div><input type="text"/><wbr/></div>`;

expect(rendered).to.equal(expected);
});
Expand Down