less 1.7.4 → 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/jsLibraryMappings.xml +0 -1
- package/.idea/workspace.xml +160 -202
- package/CHANGELOG.md +13 -0
- package/Gruntfile.js +0 -12
- package/README.md +53 -53
- package/bin/lessc +4 -1
- package/bower.json +2 -2
- package/dist/less-1.7.4.js +59 -59
- package/dist/less-1.7.4.min.js +12 -12
- package/dist/less-1.7.5.js +8008 -0
- package/dist/less-1.7.5.min.js +16 -0
- package/dist/less-rhino-1.7.4.js +48 -48
- package/dist/less-rhino-1.7.5.js +9383 -0
- package/dist/lessc-rhino-1.7.4.js +2 -2
- package/dist/lessc-rhino-1.7.5.js +449 -0
- package/lib/less/functions.js +8 -1
- package/lib/less/import-visitor.js +2 -2
- package/lib/less/index.js +3 -3
- package/lib/less/parser/parser.js.orig +1747 -0
- package/lib/less/parser.js +27 -1
- package/lib/less/tree/directive.js +4 -1
- package/lib/less/tree/element.js +6 -22
- package/lib/less/tree/rule.js +7 -4
- package/lib/less/tree/rule.js.orig +164 -0
- package/lib/less/tree/ruleset.js +8 -1
- package/lib/less/tree/selector.js +1 -1
- package/package.json +6 -6
- package/test/browser/less.js +7275 -6947
- package/test/css/comments.css +8 -0
- package/test/css/css-3.css +6 -0
- package/test/css/import.css +5 -0
- package/test/css/mixins.css +3 -0
- package/test/css/property-name-interp.css +1 -0
- package/test/css/urls.css +1 -0
- package/test/less/comments.less +14 -1
- package/test/less/css-3.less +7 -0
- package/test/less/errors/import-malformed.less +1 -1
- package/test/less/errors/import-malformed.txt +3 -3
- package/test/less/import.less +8 -2
- package/test/less/mixins.less +1 -0
- package/test/less/property-name-interp.less +4 -1
- package/test/less/property-name-interp.less.orig +59 -0
- package/test/less/urls.less +2 -1
- package/test/modify-vars.js +17 -0
- package/tmp/browser/test-runner-main.html +4 -0
- package/tmp/less.js +8295 -0
- package/build/README.md +0 -53
package/lib/less/parser.js
CHANGED
|
@@ -1411,9 +1411,19 @@ less.Parser = function Parser(env) {
|
|
|
1411
1411
|
combinator: function () {
|
|
1412
1412
|
var c = input.charAt(i);
|
|
1413
1413
|
|
|
1414
|
+
if (c === '/') {
|
|
1415
|
+
save();
|
|
1416
|
+
var slashedCombinator = $re(/^\/[a-z]+\//i);
|
|
1417
|
+
if (slashedCombinator) {
|
|
1418
|
+
forget();
|
|
1419
|
+
return new(tree.Combinator)(slashedCombinator);
|
|
1420
|
+
}
|
|
1421
|
+
restore();
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1414
1424
|
if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') {
|
|
1415
1425
|
i++;
|
|
1416
|
-
if (input.charAt(i) === '^') {
|
|
1426
|
+
if (c === '^' && input.charAt(i) === '^') {
|
|
1417
1427
|
c = '^^';
|
|
1418
1428
|
i++;
|
|
1419
1429
|
}
|
|
@@ -1568,6 +1578,7 @@ less.Parser = function Parser(env) {
|
|
|
1568
1578
|
value = this.detachedRuleset();
|
|
1569
1579
|
}
|
|
1570
1580
|
|
|
1581
|
+
this.comments();
|
|
1571
1582
|
if (!value) {
|
|
1572
1583
|
// prefer to try to parse first if its a variable or we are compressing
|
|
1573
1584
|
// but always fallback on the other one
|
|
@@ -1812,6 +1823,8 @@ less.Parser = function Parser(env) {
|
|
|
1812
1823
|
break;
|
|
1813
1824
|
}
|
|
1814
1825
|
|
|
1826
|
+
this.comments();
|
|
1827
|
+
|
|
1815
1828
|
if (hasIdentifier) {
|
|
1816
1829
|
value = this.entity();
|
|
1817
1830
|
if (!value) {
|
|
@@ -1829,6 +1842,8 @@ less.Parser = function Parser(env) {
|
|
|
1829
1842
|
}
|
|
1830
1843
|
}
|
|
1831
1844
|
|
|
1845
|
+
this.comments();
|
|
1846
|
+
|
|
1832
1847
|
if (hasBlock) {
|
|
1833
1848
|
rules = this.blockRuleset();
|
|
1834
1849
|
}
|
|
@@ -2043,9 +2058,20 @@ less.Parser = function Parser(env) {
|
|
|
2043
2058
|
return name.push(a[1]);
|
|
2044
2059
|
}
|
|
2045
2060
|
}
|
|
2061
|
+
function cutOutBlockComments() {
|
|
2062
|
+
//match block comments
|
|
2063
|
+
var a = /^\s*\/\*(?:[^*]|\*+[^\/*])*\*+\//.exec(c);
|
|
2064
|
+
if (a) {
|
|
2065
|
+
length += a[0].length;
|
|
2066
|
+
c = c.slice(a[0].length);
|
|
2067
|
+
return true;
|
|
2068
|
+
}
|
|
2069
|
+
return false;
|
|
2070
|
+
}
|
|
2046
2071
|
|
|
2047
2072
|
match(/^(\*?)/);
|
|
2048
2073
|
while (match(/^((?:[\w-]+)|(?:@\{[\w-]+\}))/)); // !
|
|
2074
|
+
while (cutOutBlockComments());
|
|
2049
2075
|
if ((name.length > 1) && match(/^\s*((?:\+_|\+)?)\s*:/)) {
|
|
2050
2076
|
// at last, we have the complete match now. move forward,
|
|
2051
2077
|
// convert name particles to tree objects and return:
|
|
@@ -24,7 +24,10 @@ tree.Directive.prototype = {
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
isRulesetLike: function() {
|
|
27
|
-
return
|
|
27
|
+
return !this.isCharset();
|
|
28
|
+
},
|
|
29
|
+
isCharset: function() {
|
|
30
|
+
return "@charset" === this.name;
|
|
28
31
|
},
|
|
29
32
|
genCSS: function (env, output) {
|
|
30
33
|
var value = this.value, rules = this.rules;
|
package/lib/less/tree/element.js
CHANGED
|
@@ -77,30 +77,14 @@ tree.Combinator = function (value) {
|
|
|
77
77
|
};
|
|
78
78
|
tree.Combinator.prototype = {
|
|
79
79
|
type: "Combinator",
|
|
80
|
-
|
|
81
|
-
''
|
|
82
|
-
' '
|
|
83
|
-
'
|
|
84
|
-
'+' : ' + ',
|
|
85
|
-
'~' : ' ~ ',
|
|
86
|
-
'>' : ' > ',
|
|
87
|
-
'|' : '|',
|
|
88
|
-
'^' : ' ^ ',
|
|
89
|
-
'^^' : ' ^^ '
|
|
90
|
-
},
|
|
91
|
-
_outputMapCompressed: {
|
|
92
|
-
'' : '',
|
|
93
|
-
' ' : ' ',
|
|
94
|
-
':' : ' :',
|
|
95
|
-
'+' : '+',
|
|
96
|
-
'~' : '~',
|
|
97
|
-
'>' : '>',
|
|
98
|
-
'|' : '|',
|
|
99
|
-
'^' : '^',
|
|
100
|
-
'^^' : '^^'
|
|
80
|
+
_noSpaceCombinators: {
|
|
81
|
+
'': true,
|
|
82
|
+
' ': true,
|
|
83
|
+
'|': true
|
|
101
84
|
},
|
|
102
85
|
genCSS: function (env, output) {
|
|
103
|
-
|
|
86
|
+
var spaceOrEmpty = (env.compress || this._noSpaceCombinators[this.value]) ? '' : ' ';
|
|
87
|
+
output.add(spaceOrEmpty + this.value + spaceOrEmpty);
|
|
104
88
|
},
|
|
105
89
|
toCSS: tree.toCSS
|
|
106
90
|
};
|
package/lib/less/tree/rule.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function (tree) {
|
|
2
2
|
|
|
3
|
-
tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline) {
|
|
3
|
+
tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline, variable) {
|
|
4
4
|
this.name = name;
|
|
5
5
|
this.value = (value instanceof tree.Value || value instanceof tree.Ruleset) ? value : new(tree.Value)([value]);
|
|
6
6
|
this.important = important ? ' ' + important.trim() : '';
|
|
@@ -8,7 +8,8 @@ tree.Rule = function (name, value, important, merge, index, currentFileInfo, inl
|
|
|
8
8
|
this.index = index;
|
|
9
9
|
this.currentFileInfo = currentFileInfo;
|
|
10
10
|
this.inline = inline || false;
|
|
11
|
-
this.variable =
|
|
11
|
+
this.variable = (variable !== undefined) ? variable
|
|
12
|
+
: (name.charAt && (name.charAt(0) === '@'));
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
tree.Rule.prototype = {
|
|
@@ -30,13 +31,14 @@ tree.Rule.prototype = {
|
|
|
30
31
|
},
|
|
31
32
|
toCSS: tree.toCSS,
|
|
32
33
|
eval: function (env) {
|
|
33
|
-
var strictMathBypass = false, name = this.name, evaldValue;
|
|
34
|
+
var strictMathBypass = false, name = this.name, variable = this.variable, evaldValue;
|
|
34
35
|
if (typeof name !== "string") {
|
|
35
36
|
// expand 'primitive' name directly to get
|
|
36
37
|
// things faster (~10% for benchmark.less):
|
|
37
38
|
name = (name.length === 1)
|
|
38
39
|
&& (name[0] instanceof tree.Keyword)
|
|
39
40
|
? name[0].value : evalName(env, name);
|
|
41
|
+
variable = false; // never treat expanded interpolation as new variable name
|
|
40
42
|
}
|
|
41
43
|
if (name === "font" && !env.strictMath) {
|
|
42
44
|
strictMathBypass = true;
|
|
@@ -54,7 +56,8 @@ tree.Rule.prototype = {
|
|
|
54
56
|
evaldValue,
|
|
55
57
|
this.important,
|
|
56
58
|
this.merge,
|
|
57
|
-
this.index, this.currentFileInfo, this.inline
|
|
59
|
+
this.index, this.currentFileInfo, this.inline,
|
|
60
|
+
variable);
|
|
58
61
|
}
|
|
59
62
|
catch(e) {
|
|
60
63
|
if (typeof e.index !== 'number') {
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
var Node = require("./node.js"),
|
|
2
|
+
Value = require("./value.js"),
|
|
3
|
+
Keyword = require("./keyword.js");
|
|
4
|
+
|
|
5
|
+
<<<<<<< HEAD
|
|
6
|
+
var Rule = function (name, value, important, merge, index, currentFileInfo, inline) {
|
|
7
|
+
=======
|
|
8
|
+
tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline, variable) {
|
|
9
|
+
>>>>>>> origin/master
|
|
10
|
+
this.name = name;
|
|
11
|
+
this.value = (value instanceof Node) ? value : new(Value)([value]); //value instanceof tree.Value || value instanceof tree.Ruleset ??
|
|
12
|
+
this.important = important ? ' ' + important.trim() : '';
|
|
13
|
+
this.merge = merge;
|
|
14
|
+
this.index = index;
|
|
15
|
+
this.currentFileInfo = currentFileInfo;
|
|
16
|
+
this.inline = inline || false;
|
|
17
|
+
this.variable = (variable !== undefined) ? variable
|
|
18
|
+
: (name.charAt && (name.charAt(0) === '@'));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
<<<<<<< HEAD
|
|
22
|
+
=======
|
|
23
|
+
tree.Rule.prototype = {
|
|
24
|
+
type: "Rule",
|
|
25
|
+
accept: function (visitor) {
|
|
26
|
+
this.value = visitor.visit(this.value);
|
|
27
|
+
},
|
|
28
|
+
genCSS: function (env, output) {
|
|
29
|
+
output.add(this.name + (env.compress ? ':' : ': '), this.currentFileInfo, this.index);
|
|
30
|
+
try {
|
|
31
|
+
this.value.genCSS(env, output);
|
|
32
|
+
}
|
|
33
|
+
catch(e) {
|
|
34
|
+
e.index = this.index;
|
|
35
|
+
e.filename = this.currentFileInfo.filename;
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
output.add(this.important + ((this.inline || (env.lastRule && env.compress)) ? "" : ";"), this.currentFileInfo, this.index);
|
|
39
|
+
},
|
|
40
|
+
toCSS: tree.toCSS,
|
|
41
|
+
eval: function (env) {
|
|
42
|
+
var strictMathBypass = false, name = this.name, variable = this.variable, evaldValue;
|
|
43
|
+
if (typeof name !== "string") {
|
|
44
|
+
// expand 'primitive' name directly to get
|
|
45
|
+
// things faster (~10% for benchmark.less):
|
|
46
|
+
name = (name.length === 1)
|
|
47
|
+
&& (name[0] instanceof tree.Keyword)
|
|
48
|
+
? name[0].value : evalName(env, name);
|
|
49
|
+
variable = false; // never treat expanded interpolation as new variable name
|
|
50
|
+
}
|
|
51
|
+
if (name === "font" && !env.strictMath) {
|
|
52
|
+
strictMathBypass = true;
|
|
53
|
+
env.strictMath = true;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
evaldValue = this.value.eval(env);
|
|
57
|
+
|
|
58
|
+
if (!this.variable && evaldValue.type === "DetachedRuleset") {
|
|
59
|
+
throw { message: "Rulesets cannot be evaluated on a property.",
|
|
60
|
+
index: this.index, filename: this.currentFileInfo.filename };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return new(tree.Rule)(name,
|
|
64
|
+
evaldValue,
|
|
65
|
+
this.important,
|
|
66
|
+
this.merge,
|
|
67
|
+
this.index, this.currentFileInfo, this.inline,
|
|
68
|
+
variable);
|
|
69
|
+
}
|
|
70
|
+
catch(e) {
|
|
71
|
+
if (typeof e.index !== 'number') {
|
|
72
|
+
e.index = this.index;
|
|
73
|
+
e.filename = this.currentFileInfo.filename;
|
|
74
|
+
}
|
|
75
|
+
throw e;
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
if (strictMathBypass) {
|
|
79
|
+
env.strictMath = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
makeImportant: function () {
|
|
84
|
+
return new(tree.Rule)(this.name,
|
|
85
|
+
this.value,
|
|
86
|
+
"!important",
|
|
87
|
+
this.merge,
|
|
88
|
+
this.index, this.currentFileInfo, this.inline);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
>>>>>>> origin/master
|
|
93
|
+
function evalName(env, name) {
|
|
94
|
+
var value = "", i, n = name.length,
|
|
95
|
+
output = {add: function (s) {value += s;}};
|
|
96
|
+
for (i = 0; i < n; i++) {
|
|
97
|
+
name[i].eval(env).genCSS(env, output);
|
|
98
|
+
}
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
Rule.prototype = new Node();
|
|
103
|
+
Rule.prototype.type = "Rule";
|
|
104
|
+
Rule.prototype.genCSS = function (env, output) {
|
|
105
|
+
output.add(this.name + (env.compress ? ':' : ': '), this.currentFileInfo, this.index);
|
|
106
|
+
try {
|
|
107
|
+
this.value.genCSS(env, output);
|
|
108
|
+
}
|
|
109
|
+
catch(e) {
|
|
110
|
+
e.index = this.index;
|
|
111
|
+
e.filename = this.currentFileInfo.filename;
|
|
112
|
+
throw e;
|
|
113
|
+
}
|
|
114
|
+
output.add(this.important + ((this.inline || (env.lastRule && env.compress)) ? "" : ";"), this.currentFileInfo, this.index);
|
|
115
|
+
};
|
|
116
|
+
Rule.prototype.eval = function (env) {
|
|
117
|
+
var strictMathBypass = false, name = this.name, evaldValue;
|
|
118
|
+
if (typeof name !== "string") {
|
|
119
|
+
// expand 'primitive' name directly to get
|
|
120
|
+
// things faster (~10% for benchmark.less):
|
|
121
|
+
name = (name.length === 1)
|
|
122
|
+
&& (name[0] instanceof Keyword)
|
|
123
|
+
? name[0].value : evalName(env, name);
|
|
124
|
+
}
|
|
125
|
+
if (name === "font" && !env.strictMath) {
|
|
126
|
+
strictMathBypass = true;
|
|
127
|
+
env.strictMath = true;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
evaldValue = this.value.eval(env);
|
|
131
|
+
|
|
132
|
+
if (!this.variable && evaldValue.type === "DetachedRuleset") {
|
|
133
|
+
throw { message: "Rulesets cannot be evaluated on a property.",
|
|
134
|
+
index: this.index, filename: this.currentFileInfo.filename };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return new(Rule)(name,
|
|
138
|
+
evaldValue,
|
|
139
|
+
this.important,
|
|
140
|
+
this.merge,
|
|
141
|
+
this.index, this.currentFileInfo, this.inline);
|
|
142
|
+
}
|
|
143
|
+
catch(e) {
|
|
144
|
+
if (typeof e.index !== 'number') {
|
|
145
|
+
e.index = this.index;
|
|
146
|
+
e.filename = this.currentFileInfo.filename;
|
|
147
|
+
}
|
|
148
|
+
throw e;
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
if (strictMathBypass) {
|
|
152
|
+
env.strictMath = false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
Rule.prototype.makeImportant = function () {
|
|
157
|
+
return new(Rule)(this.name,
|
|
158
|
+
this.value,
|
|
159
|
+
"!important",
|
|
160
|
+
this.merge,
|
|
161
|
+
this.index, this.currentFileInfo, this.inline);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
module.exports = Rule;
|
package/lib/less/tree/ruleset.js
CHANGED
|
@@ -266,6 +266,7 @@ tree.Ruleset.prototype = {
|
|
|
266
266
|
},
|
|
267
267
|
genCSS: function (env, output) {
|
|
268
268
|
var i, j,
|
|
269
|
+
charsetRuleNodes = [],
|
|
269
270
|
ruleNodes = [],
|
|
270
271
|
rulesetNodes = [],
|
|
271
272
|
rulesetNodeCnt,
|
|
@@ -306,9 +307,15 @@ tree.Ruleset.prototype = {
|
|
|
306
307
|
if (isRulesetLikeNode(rule, this.root)) {
|
|
307
308
|
rulesetNodes.push(rule);
|
|
308
309
|
} else {
|
|
309
|
-
|
|
310
|
+
//charsets should float on top of everything
|
|
311
|
+
if (rule.isCharset && rule.isCharset()) {
|
|
312
|
+
charsetRuleNodes.push(rule);
|
|
313
|
+
} else {
|
|
314
|
+
ruleNodes.push(rule);
|
|
315
|
+
}
|
|
310
316
|
}
|
|
311
317
|
}
|
|
318
|
+
ruleNodes = charsetRuleNodes.concat(ruleNodes);
|
|
312
319
|
|
|
313
320
|
// If this is the root node, we don't render
|
|
314
321
|
// a selector, or {}.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "less",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "Leaner CSS",
|
|
5
5
|
"homepage": "http://lesscss.org",
|
|
6
6
|
"author": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"test": "./test"
|
|
32
32
|
},
|
|
33
33
|
"jam": {
|
|
34
|
-
"main": "./dist/less-1.
|
|
34
|
+
"main": "./dist/less-1.7.5.js"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=0.8.0"
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"test": "grunt test"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
-
"graceful-fs": "~
|
|
43
|
+
"graceful-fs": "~3.0.2",
|
|
44
44
|
"mime": "~1.2.11",
|
|
45
|
-
"request": "~2.
|
|
46
|
-
"mkdirp": "~0.
|
|
47
|
-
"clean-css": "2.
|
|
45
|
+
"request": "~2.40.0",
|
|
46
|
+
"mkdirp": "~0.5.0",
|
|
47
|
+
"clean-css": "2.2.x",
|
|
48
48
|
"source-map": "0.1.x"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|