Skip to content

Incorrect generation of selector :not in JIT mode #5947

@pkruczynski

Description

@pkruczynski

What version of Tailwind CSS are you using?
tailwindcss@2.2.17, @tailwindcss/jit@0.1.18

What build tool (or framework if it abstracts the build tool) are you using?
laravel-mix@6.0.31, webpack@5.38.1, postcss@8.3.11

What version of Node.js are you using?
v14.18.0

What browser are you using?
Firefox 93.0, Chromium 95.0.4638.54

What operating system are you using?
Linux Mint 20.1 Ulyssa

Reproduction URL
https://play.tailwindcss.com/PT2jCzNXyi

Describe your issue

The problem is with not properly generating selector :NOT for my, custom component. When I used the specification in CSS file:

@layer components {
    #menu:not(.open) {
        > * { 
          ...
        }
    }
}

In the resulting CSS, it was generated as:

#menu:not(.\!open) > * { ... }

Due to this, it naturally doesn't work as it should. It is a false logic assumption that when I want to exclude class :not(A) - just in case, also add a reinforced class :not(B).
:not(B) -> A - and that was not my expectation. Even when two selectors are generated, they do not complement each other - but are mutually exclusive.

UPDATE:

This problem seems to only occur in JIT mode (Try to change it in the Config Tailwind Play)

A possible workaround is to use a different exclusion declaration:

@layer components {
    #menu:not([class~="open"]) {
        > * { 
          ...
        }
    }
}

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