mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
refactor mixin call arguments into a seperate function
This commit is contained in:
@@ -835,7 +835,7 @@ less.Parser = function Parser(env) {
|
||||
// selector for now.
|
||||
//
|
||||
call: function () {
|
||||
var elements = [], e, c, argsSemiColon = [], argsComma = [], args, delim, arg, nameLoop, expressions, isSemiColonSeperated, expressionContainsNamed, index = i, s = input.charAt(i), name, value, important = false;
|
||||
var elements = [], e, c, args, delim, arg, index = i, s = input.charAt(i), important = false;
|
||||
|
||||
if (s !== '.' && s !== '#') { return }
|
||||
|
||||
@@ -846,60 +846,11 @@ less.Parser = function Parser(env) {
|
||||
c = $('>');
|
||||
}
|
||||
if ($('(')) {
|
||||
expressions = [];
|
||||
while (arg = $(this.expression)) {
|
||||
nameLoop = null;
|
||||
arg.throwAwayComments();
|
||||
value = arg;
|
||||
|
||||
// Variable
|
||||
if (arg.value.length == 1) {
|
||||
var val = arg.value[0];
|
||||
if (val instanceof tree.Variable) {
|
||||
if ($(':')) {
|
||||
if (expressions.length > 0) {
|
||||
if (isSemiColonSeperated) {
|
||||
error("Cannot mix ; and , as delimiter types");
|
||||
}
|
||||
expressionContainsNamed = true;
|
||||
}
|
||||
value = expect(this.expression);
|
||||
nameLoop = (name = val.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expressions.push(value);
|
||||
|
||||
argsComma.push({ name: nameLoop, value: value });
|
||||
|
||||
if ($(',')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($(';') || isSemiColonSeperated) {
|
||||
|
||||
if (expressionContainsNamed) {
|
||||
error("Cannot mix ; and , as delimiter types");
|
||||
}
|
||||
|
||||
isSemiColonSeperated = true;
|
||||
|
||||
if (expressions.length > 1) {
|
||||
value = new(tree.Value)(expressions);
|
||||
}
|
||||
argsSemiColon.push({ name: name, value: value });
|
||||
|
||||
name = null;
|
||||
expressions = [];
|
||||
expressionContainsNamed = false;
|
||||
}
|
||||
}
|
||||
|
||||
args = this.mixin.args.call(this, true);
|
||||
expect(')');
|
||||
}
|
||||
|
||||
args = isSemiColonSeperated ? argsSemiColon : argsComma;
|
||||
args = args || [];
|
||||
|
||||
if ($(this.important)) {
|
||||
important = true;
|
||||
@@ -911,7 +862,60 @@ less.Parser = function Parser(env) {
|
||||
|
||||
restore();
|
||||
},
|
||||
args: function (isCall) {
|
||||
var expressions = [], argsSemiColon = [], isSemiColonSeperated, argsComma = [], expressionContainsNamed, name, nameLoop, value, arg, args;
|
||||
while (arg = $(this.expression)) {
|
||||
nameLoop = null;
|
||||
arg.throwAwayComments();
|
||||
value = arg;
|
||||
|
||||
// Variable
|
||||
if (arg.value.length == 1) {
|
||||
var val = arg.value[0];
|
||||
if (val instanceof tree.Variable) {
|
||||
if ($(':')) {
|
||||
if (expressions.length > 0) {
|
||||
if (isSemiColonSeperated) {
|
||||
error("Cannot mix ; and , as delimiter types");
|
||||
}
|
||||
expressionContainsNamed = true;
|
||||
}
|
||||
value = expect(this.expression);
|
||||
nameLoop = (name = val.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expressions.push(value);
|
||||
|
||||
argsComma.push({ name:nameLoop, value:value });
|
||||
|
||||
if ($(',')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($(';') || isSemiColonSeperated) {
|
||||
|
||||
if (expressionContainsNamed) {
|
||||
error("Cannot mix ; and , as delimiter types");
|
||||
}
|
||||
|
||||
isSemiColonSeperated = true;
|
||||
|
||||
if (expressions.length > 1) {
|
||||
value = new (tree.Value)(expressions);
|
||||
}
|
||||
argsSemiColon.push({ name:name, value:value });
|
||||
|
||||
name = null;
|
||||
expressions = [];
|
||||
expressionContainsNamed = false;
|
||||
}
|
||||
}
|
||||
|
||||
args = isSemiColonSeperated ? argsSemiColon : argsComma;
|
||||
return args;
|
||||
},
|
||||
//
|
||||
// A Mixin definition, with a list of parameters
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user