merge in latest 1.7.1 release

This commit is contained in:
Luke Page
2014-06-10 19:30:21 +01:00
34 changed files with 17875 additions and 63 deletions

View File

@@ -123,13 +123,7 @@ function createCSS(styles, sheet, lastModified) {
}
css.id = id;
if (css.styleSheet) { // IE
try {
css.styleSheet.cssText = styles;
} catch (e) {
throw new(Error)("Couldn't reassign styleSheet.cssText.");
}
} else {
if (!css.styleSheet) {
css.appendChild(document.createTextNode(styles));
// If new contents match contents of oldCss, don't replace oldCss
@@ -153,6 +147,17 @@ function createCSS(styles, sheet, lastModified) {
oldCss.parentNode.removeChild(oldCss);
}
// For IE.
// This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash.
// See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head
if (css.styleSheet) {
try {
css.styleSheet.cssText = styles;
} catch (e) {
throw new(Error)("Couldn't reassign styleSheet.cssText.");
}
}
// Don't update the local store if the file wasn't modified
if (lastModified && cache) {
log('saving ' + href + ' to cache.', logLevel.info);

View File

@@ -8,7 +8,7 @@ var fileCache = {};
// isFileProtocol is global
function getXMLHttpRequest() {
if (window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject)) {
if (window.XMLHttpRequest && (window.location.protocol !== "file:" || !("ActiveXObject" in window))) {
return new XMLHttpRequest();
} else {
try {
@@ -203,4 +203,4 @@ return {
}
};
};
};

View File

@@ -1,7 +1,7 @@
var path = require('path'),
url = require('url'),
request,
fs = require('fs'),
fs = require('./node/fs'),
isUrlRe = /^(?:https?:)?\/\//i;
module.exports = {
@@ -146,26 +146,33 @@ module.exports = {
return;
}
var urlStr = isUrl ? filename : url.resolve(currentDirectory, filename);
var urlStr = isUrl ? filename : url.resolve(currentDirectory, filename),
urlObj = url.parse(urlStr);
if (!urlObj.protocol) {
urlObj.protocol = "http";
urlStr = urlObj.format();
}
request.get({uri: urlStr, strictSSL: !env.insecure }, function (error, res, body) {
if (res.statusCode === 404) {
if (error) {
callback({ type: 'File', message: "resource '" + urlStr + "' gave this Error:\n "+ error +"\n" });
}
if (res && res.statusCode === 404) {
callback({ type: 'File', message: "resource '" + urlStr + "' was not found\n" });
return;
}
if (!body) {
this.warn( env, 'Warning: Empty body (HTTP '+ res.statusCode + ') returned by "' + urlStr +'"');
}
if (error) {
callback({ type: 'File', message: "resource '" + urlStr + "' gave this Error:\n "+ error +"\n" });
}
fullFilename = urlStr;
callback(null, body, fullFilename);
});
} else {
var paths = [currentDirectory].concat(env.paths);
paths.push('.');
var paths = [currentDirectory];
if (env.paths) paths.push.apply(paths, env.paths);
if (paths.indexOf('.') === -1) paths.push('.');
if (env.syncImport) {
for (var i = 0; i < paths.length; i++) {
@@ -195,7 +202,12 @@ module.exports = {
} else {
fs.readFile(fullFilename, 'utf-8', function(e, data) {
if (e) { callback(e); }
callback(null, data, fullFilename);
// do processing in the next tick to allow
// file handling to dispose
process.nextTick(function() {
callback(null, data, fullFilename);
});
});
}
});

View File

@@ -0,0 +1,10 @@
var fs;
try
{
fs = require("graceful-fs");
}
catch(e)
{
fs = require("fs");
}
module.exports = fs;

View File

@@ -221,7 +221,7 @@ var functions = {
}
},
e: function (str) {
return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str);
return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str.value);
},
escape: function (str) {
return new(tree.Anonymous)(encodeURI(str.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B").replace(/\(/g, "%28").replace(/\)/g, "%29"));
@@ -711,13 +711,9 @@ function clamp(val) {
}
tree.fround = function(env, value) {
var p;
if (env && (env.numPrecision != null)) {
p = Math.pow(10, env.numPrecision);
return Math.round(value * p) / p;
} else {
return value;
}
var p = env && env.numPrecision;
//add "epsilon" to ensure numbers like 1.000000005 (represented as 1.000000004999....) are properly rounded...
return (p == null) ? value : Number((value + 2e-16).toFixed(p));
};
tree.functionCall = function(env, currentFileInfo, environment) {

View File

@@ -59,6 +59,7 @@ var lessc_helper = {
console.log(" --strict-units=on|off that cannot be represented.");
console.log(" --global-var='VAR=VALUE' Defines a variable that can be referenced by the file.");
console.log(" --modify-var='VAR=VALUE' Modifies a variable already declared in the file.");
console.log(" --url-args='QUERYSTRING' Adds params into url tokens (e.g. 42, cb=42 or 'a=1&b=2')");
console.log("");
console.log("-------------------------- Deprecated ----------------");
console.log(" --line-numbers=TYPE Outputs filename and line numbers.");

View File

@@ -818,6 +818,11 @@ var Parser = function Parser(env) {
var rgb;
if (input.charAt(i) === '#' && (rgb = $re(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/))) {
var colorCandidateString = rgb.input.match(/^#([\w]+).*/); // strip colons, brackets, whitespaces and other characters that should not definitely be part of color string
colorCandidateString = colorCandidateString[1];
if (!colorCandidateString.match(/^[A-Fa-f0-9]+$/)) { // verify if candidate consists only of allowed HEX characters
error("Invalid HEX color code");
}
return new(tree.Color)(rgb[1]);
}
},

View File

@@ -56,7 +56,8 @@ function formatError(ctx, options) {
function writeError(ctx, options) {
options = options || {};
if (options.silent) { return; }
print(formatError(ctx, options));
var message = formatError(ctx, options);
throw new Error(message);
}
function loadStyleSheet(sheet, callback, reload, remaining) {
@@ -440,5 +441,4 @@ function writeFile(filename, content) {
writeError(e, options);
quit(1);
}
console.log("done");
}(arguments));

View File

@@ -1,7 +1,7 @@
module.exports = function (tree) {
var Anonymous = function (string, index, currentFileInfo, mapLines) {
this.value = string.value || string;
var Anonymous = function (value, index, currentFileInfo, mapLines) {
this.value = value;
this.index = index;
this.mapLines = mapLines;
this.currentFileInfo = currentFileInfo;

View File

@@ -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, originalRuleset;
args = this.arguments && this.arguments.map(function (a) {
return { name: a.name, value: a.value.eval(env) };
@@ -98,8 +98,9 @@ Call.prototype = {
try {
mixin = candidates[m].mixin;
if (!(mixin instanceof tree.mixin.Definition)) {
originalRuleset = mixin.originalRuleset || mixin;
mixin = new tree.mixin.Definition("", [], mixin.rules, null, false);
mixin.originalRuleset = mixins[m].originalRuleset || mixins[m];
mixin.originalRuleset = originalRuleset;
}
Array.prototype.push.apply(
rules, mixin.evalCall(env, args, this.important).rules);

View File

@@ -92,7 +92,7 @@ Definition.prototype = {
throw { type: 'Runtime', message: "wrong number of arguments for " + this.name +
' (' + argsLength + ' for ' + this.arity + ')' };
}
frame.prependRule(new(tree.Rule)(name, val));
evaldArguments[i] = val;
}
@@ -132,7 +132,7 @@ Definition.prototype = {
matchCondition: function (args, env) {
if (this.condition && !this.condition.eval(
new(tree.evalEnv)(env,
[this.evalParams(env, new(tree.evalEnv)(env, this.frames.concat(env.frames)), args, [])] // the parameter variables
[this.evalParams(env, new(tree.evalEnv)(env, this.frames ? this.frames.concat(env.frames) : env.frames), args, [])] // the parameter variables
.concat(this.frames) // the parent namespace/mixin frames
.concat(env.frames)))) { // the current environment frames
return false;

View File

@@ -34,8 +34,16 @@ Quoted.prototype = {
return -1;
}
var left = this.toCSS(),
var left, right;
// when comparing quoted strings allow the quote to differ
if (x.type === "Quoted" && !this.escaped && !x.escaped) {
left = x.value;
right = this.value;
} else {
left = this.toCSS();
right = x.toCSS();
}
if (left === right) {
return 0;