Skip to content

Empty class attribute duplicated with preact/compat and SSR #208

@siancatalyst

Description

@siancatalyst

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions