Building mixins should combine duplicate nested selectors
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 17k
- Forks
- 3.4k
- Avg merge
- 7h 42m
- Merged PRs (30d)
- 26
Description
I often find myself avoiding mixins because I know that the compiled CSS will have duplicate selectors, which makes for a larger file. For example, a reduced test case:
.mixin () {
a {
color: red;
}
}
div {
.mixin();
a {
text-decoration: none;
}
}
When this is compiled, the resulting output is:
div a {
color: red;
}
div a {
text-decoration: none;
}
In a perfect world, selectors inside a mixin and selectors inside the scope in which the mixin was executed would be combined when they are identical. Then, the resulting output would be the much cleaner:
div a {
color: red;
text-decoration: none;
}
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
Start by compiling the reduced mixin test case in the issue and compare its duplicate CSS selectors with the requested combined output. Done means identical nested selectors from the mixin and its surrounding scope produce one CSS rule containing both declarations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100