less / less/less.js

Extend does not ignore meaningless spaces in pseudoclasses parameters

Open
#1,579 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Pseudoclasses parameters inside extend must match perfectly. The extend expression :extend(:lang( en )) will not match selector without spaces :lang(en).

Sample input:

:lang(en) {
  lang: en;
}
.spacedLang:extend(:lang( en )){}

Actual output:

:lang(en) {
  lang: en;
}

Expected output:

:lang(en),
.spacedLang {
  lang: en;
}

Longer test case with multiple parameters types:

:lang(en) {
  lang: en;
}
:lang( en ) {
  lang: spaced en;
}
.lang:extend(:lang(en)){}
.spacedLang:extend(:lang( en )){}

:nth-child(even) {
    nth: no spaces even;
}
:nth-child( even ) {
    nth: spaces even;
}
.even:extend(:nth-child(even)){}
.spacedEven:extend(:nth-child( even )){}


:nth-child(2n+1) {
    nth: no spaces even;
}
:nth-child(2n + 1) {
    nth: spaces even;
}
.nth:extend(:nth-child(2n+1)){}
.spacedNth:extend(:nth-child(2n + 1)){}

Actual output:

:lang(en),
.lang {
  lang: en;
}
:lang( en ),
.spacedLang {
  lang: spaced en;
}
:nth-child(even),
.even {
  nth: no spaces even;
}
:nth-child( even ),
.spacedEven {
  nth: spaces even;
}
:nth-child(2n+1),
.nth {
  nth: no spaces even;
}
:nth-child(2n + 1),
.spacedNth {
  nth: spaces even;
}

Expected output:

:lang(en),
.lang,
.spacedLang {
  lang: en;
}
:lang( en ),
.lang,
.spacedLang {
  lang: spaced en;
}
:nth-child(even),
.even,
.spacedEven {
  nth: no spaces even;
}
:nth-child( even ),
.even,
.spacedEven {
  nth: spaces even;
}
:nth-child(2n+1),
.nth,
.spacedNth {
  nth: no spaces even;
}
:nth-child(2n + 1),
.nth,
.spacedNth {
  nth: spaces even;
}

Tested on lessc 1.5.0-b3

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 samples with lessc 1.5.0-b3 and compare the actual and expected selector output. Trace the extend handling for pseudoclass parameters, then add coverage for spaces in :lang(), :nth-child(), and arithmetic parameters; done means equivalent parameters match while distinct spaced definitions retain their own declarations.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.