less / less/less.js

Detached ruleset scopes affected — Recording an error reporting

Open
#2,868 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When I refer to the code in the manual for testing, I found the detached ruleset scopes affected.
( use webstorm and less 2.6.1)
View code,Please visit Less manual

Reads as follows

Variable and mixins accessible form definition win over those available in the caller:

@variable: global;
@detached-ruleset: {
    // will use global variable, because it is accessible
    // from detached-ruleset definition
    variable: @variable; 
};
selector {
    @detached-ruleset();
    @variable: value; // variable defined in caller - will be ignored
}

compiles into:

selector {
    variable: global;
}
If you add additional code in front of manual reference code,for example:
//additional code
@testvalue: 2px;
#test {
    width: @testvalue;
}

//manual reference code
@variable: global;
@detached-ruleset: {
    // will use global variable, because it is accessible
    // from detached-ruleset definition
    variable: @variable; 
};
selector {
    @detached-ruleset();
    @variable: value; // variable defined in caller - will be ignored
}

compiles into:

#test {
    width: 2px;
}
selector {
    variable: value;
}

The value of variable: global becomes value;
At present, I can not explain why.
I can only record as an error reporting.

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 with the detached-ruleset scoping example in the Less manual and reproduce both snippets using Less 2.6.1, as reported with WebStorm. Compare the generated CSS and trace the relevant compiler behavior; done means the differing results are explained and the reported scoping behavior is corrected or documented with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.