Empty class attribute duplicated with preact/compat and SSR
siancatalyst opened this issue · 1 comments
siancatalyst commented
Describe the bug
When an element is created in preact/compat with className="", rendering it to a string causes two class attributes to be output.
This can happen when using conditional classes returned from the npm classnames
function, for example.
To Reproduce
const { createElement } = require("preact/compat");
const render = require("preact-render-to-string");
console.log(render(createElement("a", { className: "" })));
Tested with preact v10.6.4 and preact-render-to-string v5.1.19
Observed behavior
<a class class></a>
Expected behavior
<a class></a>
or <a class=""></a>
rschristian commented
Thanks for the issue, found the offending bit of code:
preact-render-to-string/src/index.js
Lines 249 to 251 in 6214991
Will get a PR together here