diff --git a/lib/less/environment/node.js b/lib/less/environment/node.js index d4ef9c3c9..b8ec45e16 100644 --- a/lib/less/environment/node.js +++ b/lib/less/environment/node.js @@ -133,7 +133,7 @@ module.exports = { }, loadFile: function(env, filename, currentDirectory, callback) { var fullFilename, - data, + data, isUrl = isUrlRe.test( filename ); if (isUrl || isUrlRe.test(currentDirectory)) { @@ -206,4 +206,4 @@ module.exports = { } } } -}; \ No newline at end of file +}; diff --git a/lib/less/functions.js b/lib/less/functions.js index 3eef3f1ef..c0c1dc59e 100644 --- a/lib/less/functions.js +++ b/lib/less/functions.js @@ -342,7 +342,7 @@ var functions = { return new(tree.Dimension)(n.value * 100, '%'); }, color: function(c) { - if ((c instanceof tree.Quoted) && + if ((c instanceof tree.Quoted) && (/^#([a-f0-9]{6}|[a-f0-9]{3})$/i.test(c.value))) { return new(tree.Color)(c.value.slice(1)); } @@ -350,9 +350,9 @@ var functions = { c.keyword = undefined; return c; } - throw { - type: "Argument", - message: "argument must be a color keyword or 3/6 digit hex e.g. #FFF" + throw { + type: "Argument", + message: "argument must be a color keyword or 3/6 digit hex e.g. #FFF" }; }, iscolor: function (n) { @@ -729,5 +729,5 @@ tree.functionCall = function(env, currentFileInfo, environment) { tree.functionCall.prototype = functions; return functions; - + }; diff --git a/lib/less/index.js b/lib/less/index.js index f4730de63..043029efc 100644 --- a/lib/less/index.js +++ b/lib/less/index.js @@ -17,7 +17,7 @@ less.render = function (input, options, callback) { var css; try { css = root && root.toCSS && root.toCSS(options); - } + } catch (err) { callback(err); return; } callback(null, css); }); @@ -27,7 +27,7 @@ less.render = function (input, options, callback) { process.nextTick(function () { parser.parse(input, function (e, root) { if (e) { return ee.emit('error', e); } - try { ee.emit('success', root.toCSS(options)); } + try { ee.emit('success', root.toCSS(options)); } catch (err) { ee.emit('error', err); } }); }); @@ -83,7 +83,7 @@ less.formatError = function(ctx, options) { return message; }; - + less.writeError = function (ctx, options) { options = options || {}; if (options.silent) { return; } diff --git a/lib/less/parser.js b/lib/less/parser.js index c586feac8..b9be06c5d 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -81,20 +81,20 @@ var Parser = function Parser(env) { rootpath: currentFileInfo.rootpath, rootFilename: currentFileInfo.rootFilename }; - + less.environment.loadFile(env, path, currentFileInfo.currentDirectory, function loadFileCallback(e, contents, resolvedFilename) { if (e) { fileParsedFunc(e); return; } - // Pass on an updated rootpath if path of imported file is relative and file + // Pass on an updated rootpath if path of imported file is relative and file // is in a (sub|sup) directory - // - // Examples: + // + // Examples: // - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/', // then rootpath should become 'less/module/nav/' - // - If path of imported file is '../mixins.less' and rootpath is 'less/', + // - If path of imported file is '../mixins.less' and rootpath is 'less/', // then rootpath should become 'less/../' newFileInfo.currentDirectory = less.environment.getPath(env, resolvedFilename); if(newFileInfo.relativeUrls) { @@ -121,7 +121,7 @@ var Parser = function Parser(env) { new(less.Parser)(newEnv).parse(contents, function (e, root) { fileParsedFunc(e, root, resolvedFilename); }); - } + } }); } }; diff --git a/lib/less/tree.js b/lib/less/tree.js index 393f71b17..5073cda32 100644 --- a/lib/less/tree.js +++ b/lib/less/tree.js @@ -1,7 +1,7 @@ module.exports = function (less) { var tree = {}; - + tree.debugInfo = function(env, ctx, lineSeperator) { var result=""; if (env.dumpLineNumbers && !env.compress) { @@ -131,8 +131,8 @@ tree.Media = require('./tree/media')(tree); tree.UnicodeDescriptor = require('./tree/unicode-descriptor')(tree); tree.Negative = require('./tree/negative')(tree); tree.Extend = require('./tree/extend')(tree); -tree.RulesetCall = require('./tree/ruleset-call')(tree); +tree.RulesetCall = require('./tree/ruleset-call')(tree); return tree; -}; \ No newline at end of file +}; diff --git a/lib/less/tree/color.js b/lib/less/tree/color.js index bbeb542a4..533235f85 100644 --- a/lib/less/tree/color.js +++ b/lib/less/tree/color.js @@ -43,7 +43,7 @@ Color.prototype = { }, toCSS: function (env, doNotCompress) { var compress = env && env.compress && !doNotCompress, color, alpha; - + // `keyword` is set if this color was originally // converted from a named color string so we need // to respect this and try to output named color too. @@ -61,8 +61,8 @@ Color.prototype = { return clamp(Math.round(c), 255); }).concat(clamp(alpha, 1)) .join(',' + (compress ? '' : ' ')) + ")"; - } - + } + color = this.toRGB(); if (compress) { @@ -169,9 +169,9 @@ Color.fromKeyword = function(keyword) { c = new(Color)(data.colors[key].slice(1)); } else if (key === "transparent") { - c = new(Color)([0, 0, 0], 0); + c = new(Color)([0, 0, 0], 0); } - + if (c) { c.keyword = keyword; return c; diff --git a/lib/less/tree/mixin-call.js b/lib/less/tree/mixin-call.js index 606600aeb..de514e79e 100644 --- a/lib/less/tree/mixin-call.js +++ b/lib/less/tree/mixin-call.js @@ -20,7 +20,7 @@ Call.prototype = { eval: function (env) { var mixins, mixin, args, rules = [], match = false, i, m, f, isRecursive, isOneFound, rule, candidates = [], candidate, conditionResult = [], defaultFunc = tree.defaultFunc, - defaultResult, defNone = 0, defTrue = 1, defFalse = 2, count; + defaultResult, defNone = 0, defTrue = 1, defFalse = 2, count; args = this.arguments && this.arguments.map(function (a) { return { name: a.name, value: a.value.eval(env) }; @@ -29,12 +29,12 @@ Call.prototype = { for (i = 0; i < env.frames.length; i++) { if ((mixins = env.frames[i].find(this.selector)).length > 0) { isOneFound = true; - + // To make `default()` function independent of definition order we have two "subpasses" here. // At first we evaluate each guard *twice* (with `default() == true` and `default() == false`), // and build candidate list with corresponding flags. Then, when we know all possible matches, // we make a final decision. - + for (m = 0; m < mixins.length; m++) { mixin = mixins[m]; isRecursive = false; @@ -47,11 +47,11 @@ Call.prototype = { if (isRecursive) { continue; } - - if (mixin.matchArgs(args, env)) { + + if (mixin.matchArgs(args, env)) { candidate = {mixin: mixin, group: defNone}; - - if (mixin.matchCondition) { + + if (mixin.matchCondition) { for (f = 0; f < 2; f++) { defaultFunc.value(f); conditionResult[f] = mixin.matchCondition(args, env); @@ -63,16 +63,16 @@ Call.prototype = { } candidates.push(candidate); - } + } } else { candidates.push(candidate); } - + match = true; } } - + defaultFunc.reset(); count = [0, 0, 0]; @@ -91,7 +91,7 @@ Call.prototype = { index: this.index, filename: this.currentFileInfo.filename }; } } - + for (m = 0; m < candidates.length; m++) { candidate = candidates[m].group; if ((candidate === defNone) || (candidate === defaultResult)) { @@ -108,7 +108,7 @@ Call.prototype = { } } } - + if (match) { if (!this.currentFileInfo || !this.currentFileInfo.reference) { for (i = 0; i < rules.length; i++) {