mirror of
https://github.com/less/less.js.git
synced 2026-02-08 22:15:04 -05:00
Merge remote-tracking branch 'origin/master' into 2_0_0
Conflicts: lib/less/index.js lib/less/parser/parser.js lib/less/tree/rule.js test/less/property-name-interp.less
This commit is contained in:
@@ -21,14 +21,14 @@ less.render = function (input, options, callback) {
|
||||
}
|
||||
catch (err) { callback(err); return; }
|
||||
callback(null, css);
|
||||
});
|
||||
}, options);
|
||||
} else {
|
||||
return new PromiseConstructor(function (resolve, reject) {
|
||||
parser.parse(input, function (e, root) {
|
||||
if (e) { return reject(e); }
|
||||
try { resolve(root.toCSS(options)); }
|
||||
catch (err) { reject( err); }
|
||||
});
|
||||
}, options);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1173,6 +1173,7 @@ var Parser = function Parser(env) {
|
||||
value = this.detachedRuleset();
|
||||
}
|
||||
|
||||
parserInput.commentStore.length = 0;
|
||||
if (!value) {
|
||||
// a name returned by this.ruleProperty() is always an array of the form:
|
||||
// [string-1, ..., string-n, ""] or [string-1, ..., string-n, "+"]
|
||||
@@ -1433,6 +1434,8 @@ var Parser = function Parser(env) {
|
||||
break;
|
||||
}
|
||||
|
||||
parserInput.commentStore.length = 0;
|
||||
|
||||
if (hasIdentifier) {
|
||||
value = this.entity();
|
||||
if (!value) {
|
||||
|
||||
@@ -2,7 +2,7 @@ var Node = require("./node.js"),
|
||||
Value = require("./value.js"),
|
||||
Keyword = require("./keyword.js");
|
||||
|
||||
var Rule = function (name, value, important, merge, index, currentFileInfo, inline) {
|
||||
var Rule = function (name, value, important, merge, index, currentFileInfo, inline, variable) {
|
||||
this.name = name;
|
||||
this.value = (value instanceof Node) ? value : new(Value)([value]); //value instanceof tree.Value || value instanceof tree.Ruleset ??
|
||||
this.important = important ? ' ' + important.trim() : '';
|
||||
@@ -10,7 +10,8 @@ var Rule = function (name, value, important, merge, index, currentFileInfo, inli
|
||||
this.index = index;
|
||||
this.currentFileInfo = currentFileInfo;
|
||||
this.inline = inline || false;
|
||||
this.variable = name.charAt && (name.charAt(0) === '@');
|
||||
this.variable = (variable !== undefined) ? variable
|
||||
: (name.charAt && (name.charAt(0) === '@'));
|
||||
};
|
||||
|
||||
function evalName(env, name) {
|
||||
@@ -37,13 +38,14 @@ Rule.prototype.genCSS = function (env, output) {
|
||||
output.add(this.important + ((this.inline || (env.lastRule && env.compress)) ? "" : ";"), this.currentFileInfo, this.index);
|
||||
};
|
||||
Rule.prototype.eval = function (env) {
|
||||
var strictMathBypass = false, name = this.name, evaldValue;
|
||||
var strictMathBypass = false, name = this.name, evaldValue, variable = this.variable;
|
||||
if (typeof name !== "string") {
|
||||
// expand 'primitive' name directly to get
|
||||
// things faster (~10% for benchmark.less):
|
||||
name = (name.length === 1)
|
||||
&& (name[0] instanceof Keyword)
|
||||
? name[0].value : evalName(env, name);
|
||||
variable = false; // never treat expanded interpolation as new variable name
|
||||
}
|
||||
if (name === "font" && !env.strictMath) {
|
||||
strictMathBypass = true;
|
||||
@@ -61,7 +63,8 @@ Rule.prototype.eval = function (env) {
|
||||
evaldValue,
|
||||
this.important,
|
||||
this.merge,
|
||||
this.index, this.currentFileInfo, this.inline);
|
||||
this.index, this.currentFileInfo, this.inline,
|
||||
variable);
|
||||
}
|
||||
catch(e) {
|
||||
if (typeof e.index !== 'number') {
|
||||
|
||||
Reference in New Issue
Block a user