less.js icon indicating copy to clipboard operation
less.js copied to clipboard

fix(issue#4358): parent selector list in selector

Open puckowski opened this issue 3 months ago • 0 comments

What:

Fix for issue #4358 that correctly expands parent selectors in a list in a selector.

Why:

This Less:

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

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

currently becomes:

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

but should be:

.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;
}

I believe one existing test:

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

may need to be updated to resolve to:

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

Creating PR to discuss solution and the one failing test.

Checklist:

  • [ ] Documentation
  • [x] Added/updated unit tests
  • [x] Code complete

puckowski avatar Sep 27 '25 11:09 puckowski