less / less/less.js

`& {...}` nested class as a mixin – unspecified behaviour

Open
#2,453 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug low priority up-for-grabs
Dominant language
JavaScript
Stars
17k
Forks
3.4k
Avg merge
7h 42m
Merged PRs (30d)
26

Description

This works as expected:

.foo {
  .bar.baz;
}

.bar {
  &.baz {
    some: stuff;
  }
}
$ lessc this
.foo {
  some: stuff;
}
.bar.baz {
  some: stuff;
}

And that fails:

.foo {
  .bar.baz;
}

.bar {
  & {
    &.baz {
      some: stuff;
    }
  }
}
$ lessc that
NameError: .bar.baz is undefined in .../that on line 2, column 5:
1 .foo {
2     .bar.baz;
3 }

Funnily, it works when the declarations are the other way round:

.bar {
  & {
    &.baz {
      some: stuff;
    }
  }
}

.foo {
  .bar.baz;
}
$ lessc the-other-way-round
.bar.baz {
  some: stuff;
}
.foo {
  some: stuff;
}

I'm using lessc 2.4.0 (Less Compiler) [JavaScript].

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the three examples with lessc 2.4.0 and compare the declaration-order results. Determine the intended behavior for nested & selectors used as mixins, then use that decision to define the expected output or error for each example.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.