less/less.js — pull request #1624 by seven-phases-max (2013-10-30 03:05:55+00:00)
Title: Experimental support for mixins with interpolated selectors

#### 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.

What is supported: see included [tests](https://github.com/seven-phases-max/less.js/blob/mixins-with-interpolated-selectors/test/less/mixins-interpolated.less).

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
}
```
---

This patch also includes #1623 (its changes are important for this one to work properly).

---

Undocumented feature:
Though this patch allows a variable to contain whatever complex selector(s) 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"`).