mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Added support for property merge via +_;
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -199,14 +199,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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user