less / less/less.js

Namespace, scope and lazy loading

Open
#996 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

How is the namespace reference supposed to behave when the namespace is used before being declared? (Using mixins and variables before declaring them is legal.)

It seems like if I use mixin from namespace before declaring it, the mixin uses the caller mixins and variables scope. E.g. this:

 #abc1 { #space1 > .test1(); }
 #space1 {
  .mixin1() { color: red; }
  .test1() { .mixin1(); }
  .mixin1() { margin: 2 2 2 2; }
 }
 .mixin1() { content: "conflict"; }

compiles into:

#abc1 {
  content: "conflict";
}

The mixin test1 does not see other mixins declared in the same namespace. Is it a bug or was not supposed to use it this way?

If I put the first reference #abc1 { #space1 > .test1(); } after the #space declaration, then the mixin test1 starts to compile correctly.

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

Reproduce the two namespace-order examples from the issue and compare how the namespace, mixin, and variable scopes resolve before and after declaration. Determine the intended behavior for forward namespace references, then verify that the reported example follows that behavior consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.