Skip to content

Exclamation mark in CSS class name is not supported #3987

@Fox32

Description

@Fox32

Node.js version

v20.19.2

jsdom version

27.2.0

Minimal reproduction case

const { JSDOM } = require("jsdom");

const options = {};
const dom = new JSDOM(`
  <style>
    .visible\! { 
      color: red;
    }
  </style>
`, options);

How does similar code behave in browsers?

This works and is correctly parsed by browsers. According to the CSS grammar it is also allowed. This kind of syntax is used by tailwind.

What is the problem?

I expect this output to parse the classname as "visible!". However, the console prints Could not parse CSS stylesheet (the real error is hidden, but states that the class name is not valid).

This is an issue in the regex parsing class names in CSSOM.

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