mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Merge branch 'master' into 2_0_0
Conflicts: lib/less/browser.js lib/less/parser.js
This commit is contained in:
@@ -21,11 +21,12 @@ var logLevel = {
|
||||
};
|
||||
|
||||
// The amount of logging in the javascript console.
|
||||
// 3 - Debug, information and errors
|
||||
// 2 - Information and errors
|
||||
// 1 - Errors
|
||||
// 0 - None
|
||||
// Defaults to 2
|
||||
less.logLevel = typeof(less.logLevel) != 'undefined' ? less.logLevel : logLevel.debug;
|
||||
less.logLevel = typeof(less.logLevel) != 'undefined' ? less.logLevel : (less.env === 'development' ? logLevel.debug : logLevel.errors);
|
||||
|
||||
// Load styles asynchronously (default: false)
|
||||
//
|
||||
@@ -57,7 +58,7 @@ var typePattern = /^text\/(x-)?less$/;
|
||||
var cache = null;
|
||||
|
||||
function log(str, level) {
|
||||
if (less.env == 'development' && typeof(console) !== 'undefined' && less.logLevel >= level) {
|
||||
if (typeof(console) !== 'undefined' && less.logLevel >= level) {
|
||||
console.log('less: ' + str);
|
||||
}
|
||||
}
|
||||
@@ -159,6 +160,13 @@ function createCSS(styles, sheet, lastModified) {
|
||||
}
|
||||
}
|
||||
|
||||
function postProcessCSS(styles) {
|
||||
if (less.postProcessor && typeof less.postProcessor === 'function') {
|
||||
styles = less.postProcessor.call(styles, styles) || styles;
|
||||
}
|
||||
return styles;
|
||||
}
|
||||
|
||||
function errorHTML(e, rootHref) {
|
||||
var id = 'less-error-message:' + extractId(rootHref || "");
|
||||
var template = '<li><label>{line}</label><pre class="{class}">{content}</pre></li>';
|
||||
@@ -393,7 +401,9 @@ function initRunningMode(){
|
||||
if (e) {
|
||||
error(e, sheet.href);
|
||||
} else if (root) {
|
||||
createCSS(root.toCSS(less), sheet, env.lastModified);
|
||||
var styles = root.toCSS(less);
|
||||
styles = postProcessCSS(styles);
|
||||
createCSS(styles, sheet, env.lastModified);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -459,7 +469,9 @@ less.refresh = function (reload, modifyVars) {
|
||||
log("loading " + sheet.href + " from cache.", logLevel.info);
|
||||
} else {
|
||||
log("parsed " + sheet.href + " successfully.", logLevel.debug);
|
||||
createCSS(root.toCSS(less), sheet, env.lastModified);
|
||||
var styles = root.toCSS(less);
|
||||
styles = postProcessCSS(styles);
|
||||
createCSS(styles, sheet, env.lastModified);
|
||||
}
|
||||
log("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms', logLevel.info);
|
||||
if (env.remaining === 0) {
|
||||
|
||||
@@ -242,7 +242,16 @@ tree.functions = {
|
||||
if(!(val instanceof tree.Dimension)) {
|
||||
throw { type: "Argument", message: "the first argument to unit must be a number" + (val instanceof tree.Operation ? ". Have you forgotten parenthesis?" : "") };
|
||||
}
|
||||
return new(tree.Dimension)(val.value, unit ? unit.toCSS() : "");
|
||||
if (unit) {
|
||||
if (unit instanceof tree.Keyword) {
|
||||
unit = unit.value;
|
||||
} else {
|
||||
unit = unit.toCSS();
|
||||
}
|
||||
} else {
|
||||
unit = "";
|
||||
}
|
||||
return new(tree.Dimension)(val.value, unit);
|
||||
},
|
||||
convert: function (val, unit) {
|
||||
return val.convertTo(unit.value);
|
||||
|
||||
@@ -15,8 +15,13 @@ var less = {
|
||||
|
||||
if (callback) {
|
||||
parser.parse(input, function (e, root) {
|
||||
try { callback(e, root && root.toCSS && root.toCSS(options)); }
|
||||
catch (err) { callback(err); }
|
||||
if (e) { callback(e); return; }
|
||||
var css;
|
||||
try {
|
||||
css = root && root.toCSS && root.toCSS(options);
|
||||
}
|
||||
catch (err) { callback(err); return; }
|
||||
callback(null, css);
|
||||
});
|
||||
} else {
|
||||
ee = new (require('events').EventEmitter)();
|
||||
@@ -129,4 +134,4 @@ require('./join-selector-visitor.js');
|
||||
require('./to-css-visitor.js');
|
||||
require('./source-map-output.js');
|
||||
|
||||
module.exports = less;
|
||||
module.exports = less;
|
||||
|
||||
@@ -820,7 +820,7 @@ less.Parser = function Parser(env) {
|
||||
// black border-collapse
|
||||
//
|
||||
keyword: function () {
|
||||
var k = $re(/^[_A-Za-z-][_A-Za-z0-9-]*/);
|
||||
var k = $re(/^%|^[_A-Za-z-][_A-Za-z0-9-]*/);
|
||||
if (k) {
|
||||
return tree.Color.fromKeyword(k) || new(tree.Keyword)(k);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ tree.Keyword.prototype = {
|
||||
type: "Keyword",
|
||||
eval: function () { return this; },
|
||||
genCSS: function (env, output) {
|
||||
if (this.value === '%') { throw { type: "Syntax", message: "Invalid % without number" }; }
|
||||
output.add(this.value);
|
||||
},
|
||||
toCSS: tree.toCSS,
|
||||
|
||||
Reference in New Issue
Block a user