Skip to content

False arguments serialized as strings #129

@dy

Description

@dy

Suppose use-case for conditional applying classes:

import { render } from "preact";
import { html } from "htm/preact";

let el = document.createElement("div");
render(
  html`
    <div class="${false} ${null} ${undefined} ${"foo"}" />
  `,
  el
);

console.log(el.innerHTML);
// <div class="false null undefined foo"></div> 

Sandbox

That's unexpected that the htm serializes false/null class values literally.
That can be worked around with clsx or alike, but.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions