Merge https://github.com/less/less.js into case-insensite-units-2096

Conflicts:
	test/css/comments.css
	test/less/comments.less
This commit is contained in:
jurcovicovam
2014-09-05 10:08:54 +02:00
14 changed files with 17914 additions and 11 deletions

View File

@@ -4,7 +4,7 @@ var path = require('path'),
fs = require('./fs');
var less = {
version: [1, 7, 4],
version: [1, 7, 5],
Parser: require('./parser').Parser,
tree: require('./tree'),
render: function (input, options, callback) {

View File

@@ -1578,6 +1578,7 @@ less.Parser = function Parser(env) {
value = this.detachedRuleset();
}
this.comments();
if (!value) {
// prefer to try to parse first if its a variable or we are compressing
// but always fallback on the other one
@@ -1822,6 +1823,8 @@ less.Parser = function Parser(env) {
break;
}
this.comments();
if (hasIdentifier) {
value = this.entity();
if (!value) {
@@ -1839,6 +1842,8 @@ less.Parser = function Parser(env) {
}
}
this.comments();
if (hasBlock) {
rules = this.blockRuleset();
}
@@ -2053,9 +2058,20 @@ less.Parser = function Parser(env) {
return name.push(a[1]);
}
}
function cutOutBlockComments() {
//match block comments
var a = /^\s*\/\*(?:[^*]|\*+[^\/*])*\*+\//.exec(c);
if (a) {
length += a[0].length;
c = c.slice(a[0].length);
return true;
}
return false;
}
match(/^(\*?)/);
while (match(/^((?:[\w-]+)|(?:@\{[\w-]+\}))/)); // !
while (cutOutBlockComments());
if ((name.length > 1) && match(/^\s*((?:\+_|\+)?)\s*:/)) {
// at last, we have the complete match now. move forward,
// convert name particles to tree objects and return:

View File

@@ -1,6 +1,6 @@
(function (tree) {
tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline) {
tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline, variable) {
this.name = name;
this.value = (value instanceof tree.Value || value instanceof tree.Ruleset) ? value : new(tree.Value)([value]);
this.important = important ? ' ' + important.trim() : '';
@@ -8,7 +8,8 @@ tree.Rule = function (name, value, important, merge, index, currentFileInfo, inl
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) === '@'));
};
tree.Rule.prototype = {
@@ -30,13 +31,14 @@ tree.Rule.prototype = {
},
toCSS: tree.toCSS,
eval: function (env) {
var strictMathBypass = false, name = this.name, evaldValue;
var strictMathBypass = false, name = this.name, variable = this.variable, evaldValue;
if (typeof name !== "string") {
// expand 'primitive' name directly to get
// things faster (~10% for benchmark.less):
name = (name.length === 1)
&& (name[0] instanceof tree.Keyword)
? name[0].value : evalName(env, name);
variable = false; // never treat expanded interpolation as new variable name
}
if (name === "font" && !env.strictMath) {
strictMathBypass = true;
@@ -54,7 +56,8 @@ tree.Rule.prototype = {
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') {