Skip to content

Documentation error. Please fix it. #4326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Bahurtsev opened this issue Mar 20, 2025 · 1 comment
Open

Documentation error. Please fix it. #4326

Bahurtsev opened this issue Mar 20, 2025 · 1 comment
Labels

Comments

@Bahurtsev
Copy link

Bahurtsev commented Mar 20, 2025

On this page: https://lesscss.org/features/#extend-feature-extend-all

This example does not work:

.bucket { color: blue; }
@{variable}:extend(.bucket) {}
@variable: .selector;

compiles to:

.bucket, .selector { color: blue; }

You need to write it like this:

.bucket { color: blue; }
@{variable} { &:extend(.bucket); }
@variable: .selector;

compiles to:

.bucket, .selector { color: blue; }

As I understand it, LESS treats interpolation as "late binding", so :extend() cannot be applied to a selector that has not yet been formed at the parsing stage.

@Bahurtsev Bahurtsev added the bug label Mar 20, 2025
Copy link

dosubot bot commented Mar 20, 2025

Hello @Bahurtsev! 👋 I'm here to help you with bugs, questions, and becoming a contributor.

To address the documentation error regarding the :extend feature in LESS, the following points should be clarified:

  1. Interpolation and :extend: The documentation should clearly state that :extend cannot be directly applied to selectors formed with variables, as they do not match during parsing. Instead, it should emphasize that :extend can be used with interpolated selectors, which allows for late binding.

  2. Correct Usage Example: The correct way to use :extend with a variable is to define the variable first and then use it in a nested context. For example:

    @variable: .selector;
    @{variable} {
        &:extend(.bucket);
    }

    This compiles correctly to include both .bucket and .selector in the output.

  3. Clarification on Media Queries: The documentation should also note that :extend inside @media rules only matches selectors within the same media block and can match nested selectors.

These clarifications will help users understand the correct usage of :extend with interpolated selectors and variables in LESS [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant