Unexpected `:extend()` behavior (with `selector { selector {} }` nesting)
Open
Nobody has claimed this yet.
bug
medium priority
- Dominant language
- JavaScript
- Stars
- 17k
- Forks
- 3.4k
- Avg merge
- 7h 42m
- Merged PRs (30d)
- 26
Description
My Input
So this:
.class, .other { /* stuff */ }
.class {
.class, .other { /* more stuff */ }
}
.extension { &:extend(.class all); }
Current (1.4.1) Output
Currently compiles to this:
.class,
.other,
.extension {
/* stuff */
}
.class .class,
.class .other,
.extension .extension,
.extension .other {
/* more stuff */
}
What I'd Expect
But it seems like the result should be this:
.class,
.other,
.extension {
/* stuff */
}
.class .class,
.class .other,
.class .extension, /* this */
.extension .class, /* this */
.extension .other,
.extension .extension {
/* more stuff */
}
In other words, (almost) exactly like this compiles:
.class, .extension, .other { /* stuff */ }
.class, .extension {
.class, .other, .extension { /* more stuff */ }
/* OR */
& &, .other { /* more stuff */ }
}
Questions
So,
- Is there a reason for the current behavior vs. the other?
- What's the recommended way to get the target output? (for my best effort, see "Workaround" below)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the nested selector and :extend() examples with Less 1.4.1, then compare the current and expected CSS outputs shown in the issue. Determine whether the expected selector expansion is intended; done means the behavior is explained and, if changed, the compiler produces the requested output without regressing the demonstrated cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100