Skip to content

Experimental support for mixins with interpolated selectors#1624

Merged
lukeapage merged 2 commits intoless:masterfrom
seven-phases-max:mixins-with-interpolated-selectors
Dec 20, 2013
Merged

Experimental support for mixins with interpolated selectors#1624
lukeapage merged 2 commits intoless:masterfrom
seven-phases-max:mixins-with-interpolated-selectors

Conversation

@seven-phases-max
Copy link
Copy Markdown
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
Copy Markdown
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