mirror of
https://github.com/less/less.js.git
synced 2026-01-23 14:18:00 -05:00
catch errors on css function calls
This commit is contained in:
@@ -490,7 +490,7 @@ less.Parser = function Parser(env) {
|
||||
// The arguments are parsed with the `entities.arguments` parser.
|
||||
//
|
||||
call: function () {
|
||||
var name, args;
|
||||
var name, args, index = i;
|
||||
|
||||
if (! (name = /^([\w-]+|%)\(/.exec(chunks[j]))) return;
|
||||
|
||||
@@ -507,7 +507,7 @@ less.Parser = function Parser(env) {
|
||||
|
||||
if (! $(')')) return;
|
||||
|
||||
if (name) { return new(tree.Call)(name, args) }
|
||||
if (name) { return new(tree.Call)(name, args, index) }
|
||||
},
|
||||
arguments: function () {
|
||||
var args = [], arg;
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
//
|
||||
// A function call node.
|
||||
//
|
||||
tree.Call = function (name, args) {
|
||||
tree.Call = function (name, args, index) {
|
||||
this.name = name;
|
||||
this.args = args;
|
||||
this.index = index;
|
||||
};
|
||||
tree.Call.prototype = {
|
||||
//
|
||||
@@ -24,7 +25,12 @@ tree.Call.prototype = {
|
||||
var args = this.args.map(function (a) { return a.eval(env) });
|
||||
|
||||
if (this.name in tree.functions) { // 1.
|
||||
return tree.functions[this.name].apply(tree.functions, args);
|
||||
try {
|
||||
return tree.functions[this.name].apply(tree.functions, args);
|
||||
} catch (e) {
|
||||
throw { message: "error evaluating function `" + this.name + "`",
|
||||
index: this.index };
|
||||
}
|
||||
} else { // 2.
|
||||
return new(tree.Anonymous)(this.name +
|
||||
"(" + args.map(function (a) { return a.toCSS() }).join(', ') + ")");
|
||||
|
||||
Reference in New Issue
Block a user