Skip to content

Start tag of empty head element is not omitted #43

Closed
@0f-0b

Description

@0f-0b

Initial checklist

Affected packages and versions

hast-util-to-html@9.0.2

Link to runnable example

No response

Steps to reproduce

Run the code below.

import { toHtml } from "hast-util-to-html";

console.log(toHtml(
  {
    type: "root",
    children: [
      {
        type: "element",
        tagName: "html",
        children: [
          {
            type: "element",
            tagName: "head",
            children: [],
          },
          {
            type: "element",
            tagName: "body",
            children: [],
          },
        ],
      },
    ],
  },
  { omitOptionalTags: true },
));

Expected behavior

Empty output. The start tag of the head element is omitted because the element is empty.

Actual behavior

The output is <head>.

Affected runtime and version

node@22.8.0

Affected package manager and version

npm@10.8.3

Affected OS and version

No response

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions