Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: Tab characters at the end of identifiers cause syntax errors #1673

Copy link
Copy link

Description

@evanw
Issue body actions

Describe the bug

People write CSS like this for IE:

a::after {
    display: none \9;
}

Tools such as esbuild transform this into the following equivalent CSS (the \9 has been transformed into a \ followed by a tab character):

a::after {
    display: none \	;
}

However, cssnano incorrectly minifies this code into this CSS, which contains a syntax error:

a:after{display:none \}

This is a bug with cssnano, not with esbuild.

Expected behaviour

I expect cssnano to preserve escaped characters in CSS identifiers, and to not turn valid CSS code into code with a syntax error. A tab character in an identifier should either be printed as \ or as \9 (of course if the tab character is printed as \9, then an additional whitespace character may be needed to avoid the hex digit 9 accidentally merging with any following characters that happen to be hex digits). You can read more about how character escapes in CSS syntax work here: https://www.w3.org/TR/css-syntax-3/#consume-escaped-code-point

Steps to reproduce

  1. Open https://cssnano.github.io/cssnano/playground/ in a browser

  2. Paste the following CSS into the left textarea:

    a::after {
        display: none \	;
    }
  3. Click the Minimize button

Version

https://cssnano.github.io/cssnano/playground/

Preset

(no preset)

Environment

https://cssnano.github.io/cssnano/playground/

Package details

https://cssnano.github.io/cssnano/playground/

Additional context

See also evanw/esbuild#3929.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.