Skip to content

Nested pseudo-selector with parent symbol #4358

Closed

Description

@woody-li

To reproduce:

https://lesscss.org/less-preview/#eyJjb2RlIjoiLngge1xuICAgICY6aXMoJi5hKSB7XG4gICAgICAgIGNvbG9yOiAjZjAwO1xuICAgIH1cbiAgICAmOm5vdCgmLmIsICYuYykge1xuICAgICAgICBjb2xvcjogIzBmMDtcbiAgICB9XG5cbiAgICAmOmlzKCYtYSkge1xuICAgICAgICBjb2xvcjogI2YwMDtcbiAgICB9XG4gICAgJjpub3QoJi1iLCAmLWMpIHtcbiAgICAgICAgY29sb3I6ICMwZjA7XG4gICAgfVxufVxuIiwiYWN0aXZlVmVyc2lvbiI6IjQuNS4xIiwibWF0aCI6InBhcmVucy1kaXZpc2lvbiIsInN0cmljdFVuaXRzIjpmYWxzZX0=

.x {
    &:is(&.a) {
        color: #f00;
    }
    &:not(&.b, &.c) {
        color: #0f0;
    }

    &:is(&-a) {
        color: #f00;
    }
    &:not(&-b, &-c) {
        color: #0f0;
    }
}

Current behavior:

When the nested pseudo with single selector, it works well.
But when multiple, it doesn't parse the parent symbol(&).
Tested with :not(), :is(), :where(), and got the same result.

.x:is(.x.a) {
  color: #f00;
}
.x:not(&.b, &.c) {
  color: #0f0;
}
.x:is(.x-a) {
  color: #f00;
}
.x:not(&-b, &-c) {
  color: #0f0;
}

Expected behavior:

.x:is(.x.a) {
  color: #f00;
}
.x:not(.x.b, .x.c) {
  color: #0f0;
}
.x:is(.x-a) {
  color: #f00;
}
.x:not(.x-b, .x-c) {
  color: #0f0;
}

Environment information:

  • less version: 4.4.0

Activity

  1. added this to the 5.0 milestone on Aug 18, 2025
  2. woody-li commented on Aug 28, 2025

    @woody-li
    Author

    It seems like related to #4314 ?
    I'm not sure @puckowski

  3. puckowski commented on Aug 28, 2025

    @puckowski
    Contributor

    Thank you for the bug report. I will try to solve this issue this weekend.

  4. puckowski commented on Sep 6, 2025

    @puckowski
    Contributor

    I spent some time on this but did not come up with a fully working solution. I'll try to take another stab at it soon.

  5. puckowski commented on Sep 27, 2025

    @puckowski
    Contributor

    I think I figured out a solution in #4369

    But there is one failing existing test.

    This Less:

    .selector:not(&:hover) {
      test: global scope;
    }

    according to the current tests should become:

    .selector:not(:hover) {
      test: global scope;
    }

    but my solution expands it to:

    .selector:not(.selector:hover) {
      test: global scope;
    }

    Will discuss and see if I need to update the test or my solution.

  6. added 3 commits that reference this issue on Mar 9, 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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions