mirror of
https://github.com/less/less.js.git
synced 2026-02-08 22:15:04 -05:00
Merge branch 'master' into 2_0_0
Conflicts: lib/less/import-visitor.js lib/less/index.js
This commit is contained in:
@@ -95,6 +95,14 @@ var functions = {
|
||||
luma: function (color) {
|
||||
return new(tree.Dimension)(Math.round(color.luma() * color.alpha * 100), '%');
|
||||
},
|
||||
luminance: function (color) {
|
||||
var luminance =
|
||||
(0.2126 * color.rgb[0] / 255)
|
||||
+ (0.7152 * color.rgb[1] / 255)
|
||||
+ (0.0722 * color.rgb[2] / 255);
|
||||
|
||||
return new(tree.Dimension)(Math.round(luminance * color.alpha * 100), '%');
|
||||
},
|
||||
saturate: function (color, amount) {
|
||||
// filter: saturate(3.2);
|
||||
// should be kept as is, so check for color
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
module.exports = function (tree) {
|
||||
tree.importVisitor = function(importer, finish, evalEnv) {
|
||||
tree.importVisitor = function(importer, finish, evalEnv, onceFileDetectionMap, recursionDetector) {
|
||||
this._visitor = new tree.visitor(this);
|
||||
this._importer = importer;
|
||||
this._finish = finish;
|
||||
this.env = evalEnv || new tree.evalEnv();
|
||||
this.importCount = 0;
|
||||
this.onceFileDetectionMap = onceFileDetectionMap || {};
|
||||
this.recursionDetector = {};
|
||||
if (recursionDetector) {
|
||||
for(var fullFilename in recursionDetector) {
|
||||
if (recursionDetector.hasOwnProperty(fullFilename)) {
|
||||
this.recursionDetector[fullFilename] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
tree.importVisitor.prototype = {
|
||||
@@ -51,10 +60,22 @@ module.exports = function (tree) {
|
||||
env.importMultiple = true;
|
||||
}
|
||||
|
||||
this._importer.push(importNode.getPath(), importNode.currentFileInfo, importNode.options, function (e, root, imported, fullPath) {
|
||||
this._importer.push(importNode.getPath(), importNode.currentFileInfo, importNode.options, function (e, root, importedAtRoot, fullPath) {
|
||||
if (e && !e.filename) { e.index = importNode.index; e.filename = importNode.currentFileInfo.filename; }
|
||||
|
||||
if (imported && !env.importMultiple) { importNode.skip = imported; }
|
||||
if (!env.importMultiple) {
|
||||
if (importedAtRoot) {
|
||||
importNode.skip = true;
|
||||
} else {
|
||||
importNode.skip = function() {
|
||||
if (fullPath in importVisitor.onceFileDetectionMap) {
|
||||
return true;
|
||||
}
|
||||
importVisitor.onceFileDetectionMap[fullPath] = true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var subFinish = function(e) {
|
||||
importVisitor.importCount--;
|
||||
@@ -67,8 +88,11 @@ module.exports = function (tree) {
|
||||
if (root) {
|
||||
importNode.root = root;
|
||||
importNode.importedFilename = fullPath;
|
||||
if (!inlineCSS && !importNode.skip) {
|
||||
new(tree.importVisitor)(importVisitor._importer, subFinish, env)
|
||||
var duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector;
|
||||
|
||||
if (!inlineCSS && (env.importMultiple || !duplicateImport)) {
|
||||
importVisitor.recursionDetector[fullPath] = true;
|
||||
new(tree.importVisitor)(importVisitor._importer, subFinish, env, importVisitor.onceFileDetectionMap, importVisitor.recursionDetector)
|
||||
.run(root);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ var Parser = function Parser(env) {
|
||||
var fileParsedFunc = function (e, root, fullPath) {
|
||||
parserImports.queue.splice(parserImports.queue.indexOf(path), 1); // Remove the path from the queue
|
||||
|
||||
var importedPreviously = fullPath in parserImports.files || fullPath === rootFilename;
|
||||
var importedPreviously = fullPath === rootFilename;
|
||||
|
||||
parserImports.files[fullPath] = root; // Store the root
|
||||
|
||||
@@ -693,7 +693,7 @@ var Parser = function Parser(env) {
|
||||
//
|
||||
// Ruleset -> Rule -> Value -> Expression -> Entity
|
||||
//
|
||||
// Here's some LESS code:
|
||||
// Here's some Less code:
|
||||
//
|
||||
// .class {
|
||||
// color: #fff;
|
||||
@@ -2070,4 +2070,4 @@ Parser.serializeVars = function(vars) {
|
||||
};
|
||||
|
||||
return Parser;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -202,7 +202,7 @@ function writeFile(filename, content) {
|
||||
switch (arg) {
|
||||
case 'v':
|
||||
case 'version':
|
||||
console.log("lessc " + less.version.join('.') + " (LESS Compiler) [JavaScript]");
|
||||
console.log("lessc " + less.version.join('.') + " (Less Compiler) [JavaScript]");
|
||||
continueProcessing = false;
|
||||
break;
|
||||
case 'verbose':
|
||||
|
||||
@@ -26,7 +26,17 @@ var Color = function (rgb, a) {
|
||||
Color.prototype = {
|
||||
type: "Color",
|
||||
eval: function () { return this; },
|
||||
luma: function () { return (0.2126 * this.rgb[0] / 255) + (0.7152 * this.rgb[1] / 255) + (0.0722 * this.rgb[2] / 255); },
|
||||
luma: function () {
|
||||
var r = this.rgb[0] / 255,
|
||||
g = this.rgb[1] / 255,
|
||||
b = this.rgb[2] / 255;
|
||||
|
||||
r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4);
|
||||
g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4);
|
||||
b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4);
|
||||
|
||||
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
},
|
||||
|
||||
genCSS: function (env, output) {
|
||||
output.add(this.toCSS(env));
|
||||
|
||||
@@ -92,7 +92,14 @@ Import.prototype = {
|
||||
eval: function (env) {
|
||||
var ruleset, features = this.features && this.features.eval(env);
|
||||
|
||||
if (this.skip) { return []; }
|
||||
if (this.skip) {
|
||||
if (typeof this.skip === "function") {
|
||||
this.skip = this.skip();
|
||||
}
|
||||
if (this.skip) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
if (this.options.inline) {
|
||||
//todo needs to reference css file not import
|
||||
|
||||
Reference in New Issue
Block a user