Skip to content

&__element (BEM-style nesting) compiles to invalid selector :is(.block)__element in v4.3.3 #20441

Closed

Description

@ondrej-kaspar

Since the native CSS nesting handling was introduced in v4.3.0 (#20124), the following input:

.block {
  &__element {
    color: red;
  }
}

compiles to:

:is(.block)__element {
  color: red;
}

which is invalid CSS — :is() cannot be directly concatenated with an identifier like that.

Expected behavior

Since & is immediately followed by an identifier (no combinator or pseudo-class), it should be treated as a compound selector and produce:

.block__element {
  color: red;
}

This is how it worked before v4.3.0 when nesting was resolved by Lightning CSS, and how &:hover-style nesting (with a pseudo-class after &) still correctly resolves to :is(.block):hover.

Environment

Tailwind CSS v4.3.3

Reproduction
https://play.tailwindcss.com/nLeNDYZr4j?file=css

Activity

  1. wongjn commented on Aug 29, 2026

    @wongjn
    Collaborator

    Could you provide a git repo where it was working? In Lightning CSS playground (i.e. before 4.3), it compiles to:

    __element.block {
      color: red;
    }

    And in Vite with 4.2.4 I get:

    __element.block{color:red}

    Regardless, the nesting was always meant to follow native CSS behavior and not Sass-like behavior.

  2. ondrej-kaspar commented on Aug 29, 2026

    @ondrej-kaspar
    Author

    @wongjn the same code was working with version 4.3.0, when I upgraded to the latest version (4.3.3), compiled CSS was broken (I haven't tried 4.3.1, 4.3.2).

    I'm using postcss-nested plugin.

  3. converted this issue into a discussion #20443 on Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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