This commit is contained in:
Luke Page
2014-02-09 20:42:13 +00:00
4 changed files with 57 additions and 8 deletions

View File

@@ -1484,7 +1484,7 @@ less.Parser = function Parser(env) {
}
},
rule: function (tryAnonymous) {
var name, value, c = input.charAt(i), important, merge = false;
var name, value, c = input.charAt(i), important, merge;
save();
if (c === '.' || c === '#' || c === '&') { return; }
@@ -1502,7 +1502,7 @@ less.Parser = function Parser(env) {
// a name returned by this.ruleProperty() is always an array of the form:
// [string-1, ..., string-n, ""] or [string-1, ..., string-n, "+"]
// where each item is a tree.Keyword or tree.Variable
merge = name.pop && (name.pop().value === "+");
merge = name.pop && name.pop().value;
if (value && this.end()) {
return new (tree.Rule)(name, value, important, merge, memo, env.currentFileInfo);
@@ -1944,7 +1944,7 @@ less.Parser = function Parser(env) {
match(/^(\*?)/);
while (match(/^((?:[\w-]+)|(?:@\{[\w-]+\}))/)); // !
if ((name.length > 1) && match(/^\s*(\+?)\s*:/)) {
if ((name.length > 1) && match(/^\s*((?:\+_|\+)?)\s*:/)) {
// at last, we have the complete match now. move forward,
// convert name particles to tree objects and return:
skipWhitespace(length);

View File

@@ -202,14 +202,36 @@
}
Object.keys(groups).map(function (k) {
function toExpression(values) {
return new (tree.Expression)(values.map(function (p) {
return p.value;
}));
}
function toValue(values) {
return new (tree.Value)(values.map(function (p) {
return p;
}));
}
parts = groups[k];
if (parts.length > 1) {
rule = parts[0];
rule.value = new (tree.Value)(parts.map(function (p) {
return p.value;
}));
var spacedGroups = [];
var lastSpacedGroup = [];
parts.map(function (p) {
if (p.merge==="+") {
if (lastSpacedGroup.length > 0) {
spacedGroups.push(toExpression(lastSpacedGroup));
}
lastSpacedGroup = [];
}
lastSpacedGroup.push(p);
});
spacedGroups.push(toExpression(lastSpacedGroup));
rule.value = toValue(spacedGroups);
}
});
}

View File

@@ -24,3 +24,11 @@
transform: t1, t2, t3;
background: b1, b2, b3;
}
.test-spaced {
transform: t1 t2 t3;
background: b1 b2, b3;
}
.test-interleaved-with-spaced {
transform: t1s, t2 t3s, t4 t5s t6s;
background: b1 b2s, b3, b4;
}

View File

@@ -56,4 +56,23 @@
transform+: t2;
background+: b2, b3;
transform+: t3;
}
}
.test-spaced {
transform+_: t1;
background+_: b1;
transform+_: t2;
background+_: b2, b3;
transform+_: t3;
}
.test-interleaved-with-spaced {
transform+_: t1s;
transform+: t2;
background+: b1;
transform+_: t3s;
transform+: t4 t5s;
background+_: b2s, b3;
transform+_: t6s;
background+: b4;
}