Add parent selector to user variable

This commit is contained in:
Luke Page
2012-08-19 12:02:58 +01:00
parent 0a5245b2c3
commit 85ddc9f4e7
3 changed files with 43 additions and 2 deletions

View File

@@ -1001,10 +1001,29 @@ less.Parser = function Parser(env) {
selector: function () {
var sel, e, elements = [], c, match;
if ($('(')) {
if (peek(/^&?\(/)) {
// variable selectors:
// allow & before a selector to allow variable selectors
// to be at the same level, e.g.
// .a {
// &(~".b") {
//
// Ideally this would be part of the element function.. this would allow
// (@a).b(@c)
// however this syntax conflicts with the supported syntax
// :nth-child(@a)
// vs
// .a:hover(@a)
e = $('&');
$('(');
if (e) {
elements.push(new(tree.Element)('', e, i));
}
sel = $(this.entity);
expect(')');
return new(tree.Selector)([new(tree.Element)('', sel, i)]);
elements.push(new(tree.Element)('', sel, i));
return new(tree.Selector)(elements);
}
while (e = $(this.element)) {