Skip to content
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

Experimental support for mixins with interpolated selectors #1624

Merged
merged 2 commits into from
Dec 20, 2013
Merged

Experimental support for mixins with interpolated selectors #1624

merged 2 commits into from
Dec 20, 2013

Conversation

seven-phases-max
Copy link
Member

Experimental support for mixins with interpolated selectors (#1196).

This is no doubt hackish patch (quick and dirty). However since it introduces no breaking changes I hope it can serve as a temporary solution for #1196, #1399.

What is supported: see included tests.

What is not supported: matching for selectors concatenated across nesting boundary (the same way and for the same reason this does not work with regular mixins), i.e.:

@c: c;
.a {
    &-b    {}
    &-@{c} {}
}

test {
    .a-b; // error, undefined
    .a-c; // error, undefined
}

Furthermore, this patch does not solve any scope visibilty problems mentioned in #1399.


Undocumented feature:
Though this patch allows a variable to contain whatever complex selector it might be and such selector will be matched correctly, for example:

@v1: 42;
@v2: ~".a >.b.c .d + #e~ #f";
.a > .b.c .d + #e ~ #f {
    &.g@{v1}-@{v2}-banana {
        boo: 1;
    }
}

.test {
    .a.b.c.d#e#f.g42-.a.b.c.d#e#f-banana; // OK
}

It would make sense to leave this undocumented and never recommend to use anything like this because such possibility may be not so easy to support in future. So basically, a recommendation is: a variable used in an interpolated selector should not contain anything beyond a single selector element and/or a naked string (e.g. foo, ~".foo" or ~"#foo").

lukeapage added a commit that referenced this pull request Dec 20, 2013
…ed-selectors

Experimental support for mixins with interpolated selectors
@lukeapage lukeapage merged commit 5196277 into less:master Dec 20, 2013
@jonschlinkert
Copy link
Contributor

👍

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

Successfully merging this pull request may close these issues.

3 participants