less 2.6.0 → 2.6.1
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/CHANGELOG.md +10 -1
- package/README.md +2 -2
- package/dist/less.js +240 -209
- package/dist/less.min.js +7 -6
- package/lib/less/functions/color.js +5 -2
- package/lib/less/index.js +1 -1
- package/lib/less/parser/parser-input.js +68 -68
- package/lib/less/parser/parser.js +67 -39
- package/lib/less/tree/mixin-definition.js +1 -1
- package/lib/less/tree/ruleset.js +85 -85
- package/lib/less/tree/unit.js +2 -2
- package/lib/less-browser/error-reporting.js +10 -10
- package/package.json +16 -16
- package/test/browser/less.js +8 -7
- package/test/css/comments2.css +6 -0
- package/test/css/no-strict-math/mixins-guards.css +12 -0
- package/test/less/comments2.less +11 -0
- package/test/less/no-strict-math/mixins-guards.less +25 -0
- package/test/less-bom/comments2.less +11 -0
- package/test/less-bom/no-strict-math/mixins-guards.less +25 -0
|
@@ -43,6 +43,9 @@ colorFunctions = {
|
|
|
43
43
|
return colorFunctions.hsla(h, s, l, 1.0);
|
|
44
44
|
},
|
|
45
45
|
hsla: function (h, s, l, a) {
|
|
46
|
+
|
|
47
|
+
var m1, m2;
|
|
48
|
+
|
|
46
49
|
function hue(h) {
|
|
47
50
|
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
|
|
48
51
|
if (h * 6 < 1) {
|
|
@@ -62,8 +65,8 @@ colorFunctions = {
|
|
|
62
65
|
h = (number(h) % 360) / 360;
|
|
63
66
|
s = clamp(number(s)); l = clamp(number(l)); a = clamp(number(a));
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
|
|
69
|
+
m1 = l * 2 - m2;
|
|
67
70
|
|
|
68
71
|
return colorFunctions.rgba(hue(h + 1 / 3) * 255,
|
|
69
72
|
hue(h) * 255,
|
package/lib/less/index.js
CHANGED
|
@@ -2,7 +2,7 @@ module.exports = function(environment, fileManagers) {
|
|
|
2
2
|
var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;
|
|
3
3
|
|
|
4
4
|
var less = {
|
|
5
|
-
version: [2, 6,
|
|
5
|
+
version: [2, 6, 1],
|
|
6
6
|
data: require('./data'),
|
|
7
7
|
tree: require('./tree'),
|
|
8
8
|
Environment: (Environment = require("./environment/environment")),
|
|
@@ -11,6 +11,74 @@ module.exports = function() {
|
|
|
11
11
|
currentPos, // index of current chunk, in `input`
|
|
12
12
|
parserInput = {};
|
|
13
13
|
|
|
14
|
+
var CHARCODE_SPACE = 32,
|
|
15
|
+
CHARCODE_TAB = 9,
|
|
16
|
+
CHARCODE_LF = 10,
|
|
17
|
+
CHARCODE_CR = 13,
|
|
18
|
+
CHARCODE_PLUS = 43,
|
|
19
|
+
CHARCODE_COMMA = 44,
|
|
20
|
+
CHARCODE_FORWARD_SLASH = 47,
|
|
21
|
+
CHARCODE_9 = 57;
|
|
22
|
+
|
|
23
|
+
function skipWhitespace(length) {
|
|
24
|
+
var oldi = parserInput.i, oldj = j,
|
|
25
|
+
curr = parserInput.i - currentPos,
|
|
26
|
+
endIndex = parserInput.i + current.length - curr,
|
|
27
|
+
mem = (parserInput.i += length),
|
|
28
|
+
inp = input,
|
|
29
|
+
c, nextChar, comment;
|
|
30
|
+
|
|
31
|
+
for (; parserInput.i < endIndex; parserInput.i++) {
|
|
32
|
+
c = inp.charCodeAt(parserInput.i);
|
|
33
|
+
|
|
34
|
+
if (parserInput.autoCommentAbsorb && c === CHARCODE_FORWARD_SLASH) {
|
|
35
|
+
nextChar = inp.charAt(parserInput.i + 1);
|
|
36
|
+
if (nextChar === '/') {
|
|
37
|
+
comment = {index: parserInput.i, isLineComment: true};
|
|
38
|
+
var nextNewLine = inp.indexOf("\n", parserInput.i + 2);
|
|
39
|
+
if (nextNewLine < 0) {
|
|
40
|
+
nextNewLine = endIndex;
|
|
41
|
+
}
|
|
42
|
+
parserInput.i = nextNewLine;
|
|
43
|
+
comment.text = inp.substr(comment.i, parserInput.i - comment.i);
|
|
44
|
+
parserInput.commentStore.push(comment);
|
|
45
|
+
continue;
|
|
46
|
+
} else if (nextChar === '*') {
|
|
47
|
+
var nextStarSlash = inp.indexOf("*/", parserInput.i + 2);
|
|
48
|
+
if (nextStarSlash >= 0) {
|
|
49
|
+
comment = {
|
|
50
|
+
index: parserInput.i,
|
|
51
|
+
text: inp.substr(parserInput.i, nextStarSlash + 2 - parserInput.i),
|
|
52
|
+
isLineComment: false
|
|
53
|
+
};
|
|
54
|
+
parserInput.i += comment.text.length - 1;
|
|
55
|
+
parserInput.commentStore.push(comment);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if ((c !== CHARCODE_SPACE) && (c !== CHARCODE_LF) && (c !== CHARCODE_TAB) && (c !== CHARCODE_CR)) {
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
current = current.slice(length + parserInput.i - mem + curr);
|
|
68
|
+
currentPos = parserInput.i;
|
|
69
|
+
|
|
70
|
+
if (!current.length) {
|
|
71
|
+
if (j < chunks.length - 1) {
|
|
72
|
+
current = chunks[++j];
|
|
73
|
+
skipWhitespace(0); // skip space at the beginning of a chunk
|
|
74
|
+
return true; // things changed
|
|
75
|
+
}
|
|
76
|
+
parserInput.finished = true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return oldi !== parserInput.i || oldj !== j;
|
|
80
|
+
}
|
|
81
|
+
|
|
14
82
|
parserInput.save = function() {
|
|
15
83
|
currentPos = parserInput.i;
|
|
16
84
|
saveStack.push( { current: current, i: parserInput.i, j: j });
|
|
@@ -105,78 +173,10 @@ module.exports = function() {
|
|
|
105
173
|
return null;
|
|
106
174
|
};
|
|
107
175
|
|
|
108
|
-
var CHARCODE_SPACE = 32,
|
|
109
|
-
CHARCODE_TAB = 9,
|
|
110
|
-
CHARCODE_LF = 10,
|
|
111
|
-
CHARCODE_CR = 13,
|
|
112
|
-
CHARCODE_PLUS = 43,
|
|
113
|
-
CHARCODE_COMMA = 44,
|
|
114
|
-
CHARCODE_FORWARD_SLASH = 47,
|
|
115
|
-
CHARCODE_9 = 57;
|
|
116
|
-
|
|
117
176
|
parserInput.autoCommentAbsorb = true;
|
|
118
177
|
parserInput.commentStore = [];
|
|
119
178
|
parserInput.finished = false;
|
|
120
179
|
|
|
121
|
-
var skipWhitespace = function(length) {
|
|
122
|
-
var oldi = parserInput.i, oldj = j,
|
|
123
|
-
curr = parserInput.i - currentPos,
|
|
124
|
-
endIndex = parserInput.i + current.length - curr,
|
|
125
|
-
mem = (parserInput.i += length),
|
|
126
|
-
inp = input,
|
|
127
|
-
c, nextChar, comment;
|
|
128
|
-
|
|
129
|
-
for (; parserInput.i < endIndex; parserInput.i++) {
|
|
130
|
-
c = inp.charCodeAt(parserInput.i);
|
|
131
|
-
|
|
132
|
-
if (parserInput.autoCommentAbsorb && c === CHARCODE_FORWARD_SLASH) {
|
|
133
|
-
nextChar = inp.charAt(parserInput.i + 1);
|
|
134
|
-
if (nextChar === '/') {
|
|
135
|
-
comment = {index: parserInput.i, isLineComment: true};
|
|
136
|
-
var nextNewLine = inp.indexOf("\n", parserInput.i + 2);
|
|
137
|
-
if (nextNewLine < 0) {
|
|
138
|
-
nextNewLine = endIndex;
|
|
139
|
-
}
|
|
140
|
-
parserInput.i = nextNewLine;
|
|
141
|
-
comment.text = inp.substr(comment.i, parserInput.i - comment.i);
|
|
142
|
-
parserInput.commentStore.push(comment);
|
|
143
|
-
continue;
|
|
144
|
-
} else if (nextChar === '*') {
|
|
145
|
-
var nextStarSlash = inp.indexOf("*/", parserInput.i + 2);
|
|
146
|
-
if (nextStarSlash >= 0) {
|
|
147
|
-
comment = {
|
|
148
|
-
index: parserInput.i,
|
|
149
|
-
text: inp.substr(parserInput.i, nextStarSlash + 2 - parserInput.i),
|
|
150
|
-
isLineComment: false
|
|
151
|
-
};
|
|
152
|
-
parserInput.i += comment.text.length - 1;
|
|
153
|
-
parserInput.commentStore.push(comment);
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if ((c !== CHARCODE_SPACE) && (c !== CHARCODE_LF) && (c !== CHARCODE_TAB) && (c !== CHARCODE_CR)) {
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
current = current.slice(length + parserInput.i - mem + curr);
|
|
166
|
-
currentPos = parserInput.i;
|
|
167
|
-
|
|
168
|
-
if (!current.length) {
|
|
169
|
-
if (j < chunks.length - 1) {
|
|
170
|
-
current = chunks[++j];
|
|
171
|
-
skipWhitespace(0); // skip space at the beginning of a chunk
|
|
172
|
-
return true; // things changed
|
|
173
|
-
}
|
|
174
|
-
parserInput.finished = true;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return oldi !== parserInput.i || oldj !== j;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
180
|
// Same as $(), but don't change the state of the parser,
|
|
181
181
|
// just return the match.
|
|
182
182
|
parserInput.peek = function(tok) {
|
|
@@ -41,9 +41,21 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
41
41
|
var parsers,
|
|
42
42
|
parserInput = getParserInput();
|
|
43
43
|
|
|
44
|
+
function error(msg, type) {
|
|
45
|
+
throw new LessError(
|
|
46
|
+
{
|
|
47
|
+
index: parserInput.i,
|
|
48
|
+
filename: fileInfo.filename,
|
|
49
|
+
type: type || 'Syntax',
|
|
50
|
+
message: msg
|
|
51
|
+
},
|
|
52
|
+
imports
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
44
56
|
function expect(arg, msg, index) {
|
|
45
57
|
// some older browsers return typeof 'function' for RegExp
|
|
46
|
-
var result = (
|
|
58
|
+
var result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg);
|
|
47
59
|
if (result) {
|
|
48
60
|
return result;
|
|
49
61
|
}
|
|
@@ -59,18 +71,6 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
59
71
|
error(msg || "expected '" + arg + "' got '" + parserInput.currentChar() + "'");
|
|
60
72
|
}
|
|
61
73
|
|
|
62
|
-
function error(msg, type) {
|
|
63
|
-
throw new LessError(
|
|
64
|
-
{
|
|
65
|
-
index: parserInput.i,
|
|
66
|
-
filename: fileInfo.filename,
|
|
67
|
-
type: type || 'Syntax',
|
|
68
|
-
message: msg
|
|
69
|
-
},
|
|
70
|
-
imports
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
74
|
function getDebugInfo(index) {
|
|
75
75
|
var filename = fileInfo.filename;
|
|
76
76
|
|
|
@@ -325,26 +325,6 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
325
325
|
}
|
|
326
326
|
},
|
|
327
327
|
|
|
328
|
-
namedColor: function () {
|
|
329
|
-
parserInput.save();
|
|
330
|
-
var autoCommentAbsorb = parserInput.autoCommentAbsorb;
|
|
331
|
-
parserInput.autoCommentAbsorb = false;
|
|
332
|
-
var k = parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]*/);
|
|
333
|
-
parserInput.autoCommentAbsorb = autoCommentAbsorb;
|
|
334
|
-
if (!k) {
|
|
335
|
-
parserInput.forget();
|
|
336
|
-
return ;
|
|
337
|
-
}
|
|
338
|
-
var result = tree.Color.fromKeyword(k);
|
|
339
|
-
if (!result) {
|
|
340
|
-
parserInput.restore();
|
|
341
|
-
} else {
|
|
342
|
-
parserInput.forget();
|
|
343
|
-
return result;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
},
|
|
347
|
-
|
|
348
328
|
//
|
|
349
329
|
// A function call
|
|
350
330
|
//
|
|
@@ -511,8 +491,24 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
511
491
|
}
|
|
512
492
|
return new(tree.Color)(rgb[1], undefined, '#' + colorCandidateString);
|
|
513
493
|
}
|
|
494
|
+
},
|
|
514
495
|
|
|
515
|
-
|
|
496
|
+
colorKeyword: function () {
|
|
497
|
+
parserInput.save();
|
|
498
|
+
var autoCommentAbsorb = parserInput.autoCommentAbsorb;
|
|
499
|
+
parserInput.autoCommentAbsorb = false;
|
|
500
|
+
var k = parserInput.$re(/^[A-Za-z]+/);
|
|
501
|
+
parserInput.autoCommentAbsorb = autoCommentAbsorb;
|
|
502
|
+
if (!k) {
|
|
503
|
+
parserInput.forget();
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
parserInput.restore();
|
|
507
|
+
var color = tree.Color.fromKeyword(k);
|
|
508
|
+
if (color) {
|
|
509
|
+
parserInput.$str(k);
|
|
510
|
+
return color;
|
|
511
|
+
}
|
|
516
512
|
},
|
|
517
513
|
|
|
518
514
|
//
|
|
@@ -591,7 +587,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
591
587
|
rulesetCall: function () {
|
|
592
588
|
var name;
|
|
593
589
|
|
|
594
|
-
if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\w-]+)\
|
|
590
|
+
if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\w-]+)\(\s*\)\s*;/))) {
|
|
595
591
|
return new tree.RulesetCall(name[1]);
|
|
596
592
|
}
|
|
597
593
|
},
|
|
@@ -1644,12 +1640,44 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1644
1640
|
}
|
|
1645
1641
|
},
|
|
1646
1642
|
parenthesisCondition: function () {
|
|
1643
|
+
function tryConditionFollowedByParenthesis(me) {
|
|
1644
|
+
var body;
|
|
1645
|
+
parserInput.save();
|
|
1646
|
+
body = me.condition();
|
|
1647
|
+
if (!body) {
|
|
1648
|
+
parserInput.restore();
|
|
1649
|
+
return ;
|
|
1650
|
+
}
|
|
1651
|
+
if (!parserInput.$char(')')) {
|
|
1652
|
+
parserInput.restore();
|
|
1653
|
+
return ;
|
|
1654
|
+
}
|
|
1655
|
+
parserInput.forget();
|
|
1656
|
+
return body;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1647
1659
|
var body;
|
|
1660
|
+
parserInput.save();
|
|
1648
1661
|
if (!parserInput.$str("(")) {
|
|
1662
|
+
parserInput.restore();
|
|
1649
1663
|
return ;
|
|
1650
1664
|
}
|
|
1651
|
-
body =
|
|
1652
|
-
|
|
1665
|
+
body = tryConditionFollowedByParenthesis(this);
|
|
1666
|
+
if (body) {
|
|
1667
|
+
parserInput.forget();
|
|
1668
|
+
return body;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
body = this.atomicCondition();
|
|
1672
|
+
if (!body) {
|
|
1673
|
+
parserInput.restore();
|
|
1674
|
+
return ;
|
|
1675
|
+
}
|
|
1676
|
+
if (!parserInput.$char(')')) {
|
|
1677
|
+
parserInput.restore("expected ')' got '" + parserInput.currentChar() + "'");
|
|
1678
|
+
return ;
|
|
1679
|
+
}
|
|
1680
|
+
parserInput.forget();
|
|
1653
1681
|
return body;
|
|
1654
1682
|
},
|
|
1655
1683
|
atomicCondition: function () {
|
|
@@ -1706,8 +1734,8 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
1706
1734
|
}
|
|
1707
1735
|
|
|
1708
1736
|
var o = this.sub() || entities.dimension() ||
|
|
1709
|
-
entities.variable() ||
|
|
1710
|
-
entities.call() || entities.
|
|
1737
|
+
entities.color() || entities.variable() ||
|
|
1738
|
+
entities.call() || entities.colorKeyword();
|
|
1711
1739
|
|
|
1712
1740
|
if (negate) {
|
|
1713
1741
|
o.parensInOp = true;
|
|
@@ -127,7 +127,7 @@ Definition.prototype.makeImportant = function() {
|
|
|
127
127
|
return r;
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
|
-
var result = new Definition
|
|
130
|
+
var result = new Definition(this.name, this.params, rules, this.condition, this.variadic, this.frames);
|
|
131
131
|
return result;
|
|
132
132
|
};
|
|
133
133
|
Definition.prototype.eval = function (context) {
|
package/lib/less/tree/ruleset.js
CHANGED
|
@@ -463,6 +463,91 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) {
|
|
|
463
463
|
return selector;
|
|
464
464
|
}
|
|
465
465
|
|
|
466
|
+
// joins selector path from `beginningPath` with selector path in `addPath`
|
|
467
|
+
// `replacedElement` contains element that is being replaced by `addPath`
|
|
468
|
+
// returns concatenated path
|
|
469
|
+
function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) {
|
|
470
|
+
var newSelectorPath, lastSelector, newJoinedSelector;
|
|
471
|
+
// our new selector path
|
|
472
|
+
newSelectorPath = [];
|
|
473
|
+
|
|
474
|
+
//construct the joined selector - if & is the first thing this will be empty,
|
|
475
|
+
// if not newJoinedSelector will be the last set of elements in the selector
|
|
476
|
+
if (beginningPath.length > 0) {
|
|
477
|
+
newSelectorPath = beginningPath.slice(0);
|
|
478
|
+
lastSelector = newSelectorPath.pop();
|
|
479
|
+
newJoinedSelector = originalSelector.createDerived(lastSelector.elements.slice(0));
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
newJoinedSelector = originalSelector.createDerived([]);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (addPath.length > 0) {
|
|
486
|
+
// /deep/ is a combinator that is valid without anything in front of it
|
|
487
|
+
// so if the & does not have a combinator that is "" or " " then
|
|
488
|
+
// and there is a combinator on the parent, then grab that.
|
|
489
|
+
// this also allows + a { & .b { .a & { ... though not sure why you would want to do that
|
|
490
|
+
var combinator = replacedElement.combinator, parentEl = addPath[0].elements[0];
|
|
491
|
+
if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) {
|
|
492
|
+
combinator = parentEl.combinator;
|
|
493
|
+
}
|
|
494
|
+
// join the elements so far with the first part of the parent
|
|
495
|
+
newJoinedSelector.elements.push(new Element(combinator, parentEl.value, replacedElement.index, replacedElement.currentFileInfo));
|
|
496
|
+
newJoinedSelector.elements = newJoinedSelector.elements.concat(addPath[0].elements.slice(1));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// now add the joined selector - but only if it is not empty
|
|
500
|
+
if (newJoinedSelector.elements.length !== 0) {
|
|
501
|
+
newSelectorPath.push(newJoinedSelector);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
//put together the parent selectors after the join (e.g. the rest of the parent)
|
|
505
|
+
if (addPath.length > 1) {
|
|
506
|
+
var restOfPath = addPath.slice(1);
|
|
507
|
+
restOfPath = restOfPath.map(function (selector) {
|
|
508
|
+
return selector.createDerived(selector.elements, []);
|
|
509
|
+
});
|
|
510
|
+
newSelectorPath = newSelectorPath.concat(restOfPath);
|
|
511
|
+
}
|
|
512
|
+
return newSelectorPath;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// joins selector path from `beginningPath` with every selector path in `addPaths` array
|
|
516
|
+
// `replacedElement` contains element that is being replaced by `addPath`
|
|
517
|
+
// returns array with all concatenated paths
|
|
518
|
+
function addAllReplacementsIntoPath( beginningPath, addPaths, replacedElement, originalSelector, result) {
|
|
519
|
+
var j;
|
|
520
|
+
for (j = 0; j < beginningPath.length; j++) {
|
|
521
|
+
var newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector);
|
|
522
|
+
result.push(newSelectorPath);
|
|
523
|
+
}
|
|
524
|
+
return result;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function mergeElementsOnToSelectors(elements, selectors) {
|
|
528
|
+
var i, sel;
|
|
529
|
+
|
|
530
|
+
if (elements.length === 0) {
|
|
531
|
+
return ;
|
|
532
|
+
}
|
|
533
|
+
if (selectors.length === 0) {
|
|
534
|
+
selectors.push([ new Selector(elements) ]);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
for (i = 0; i < selectors.length; i++) {
|
|
539
|
+
sel = selectors[i];
|
|
540
|
+
|
|
541
|
+
// if the previous thing in sel is a parent this needs to join on to it
|
|
542
|
+
if (sel.length > 0) {
|
|
543
|
+
sel[sel.length - 1] = sel[sel.length - 1].createDerived(sel[sel.length - 1].elements.concat(elements));
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
sel.push(new Selector(elements));
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
466
551
|
// replace all parent selectors inside `inSelector` by content of `context` array
|
|
467
552
|
// resulting selectors are returned inside `paths` array
|
|
468
553
|
// returns true if `inSelector` contained at least one parent selector
|
|
@@ -583,91 +668,6 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) {
|
|
|
583
668
|
return hadParentSelector;
|
|
584
669
|
}
|
|
585
670
|
|
|
586
|
-
// joins selector path from `beginningPath` with selector path in `addPath`
|
|
587
|
-
// `replacedElement` contains element that is being replaced by `addPath`
|
|
588
|
-
// returns concatenated path
|
|
589
|
-
function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) {
|
|
590
|
-
var newSelectorPath, lastSelector, newJoinedSelector;
|
|
591
|
-
// our new selector path
|
|
592
|
-
newSelectorPath = [];
|
|
593
|
-
|
|
594
|
-
//construct the joined selector - if & is the first thing this will be empty,
|
|
595
|
-
// if not newJoinedSelector will be the last set of elements in the selector
|
|
596
|
-
if (beginningPath.length > 0) {
|
|
597
|
-
newSelectorPath = beginningPath.slice(0);
|
|
598
|
-
lastSelector = newSelectorPath.pop();
|
|
599
|
-
newJoinedSelector = originalSelector.createDerived(lastSelector.elements.slice(0));
|
|
600
|
-
}
|
|
601
|
-
else {
|
|
602
|
-
newJoinedSelector = originalSelector.createDerived([]);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
if (addPath.length > 0) {
|
|
606
|
-
// /deep/ is a combinator that is valid without anything in front of it
|
|
607
|
-
// so if the & does not have a combinator that is "" or " " then
|
|
608
|
-
// and there is a combinator on the parent, then grab that.
|
|
609
|
-
// this also allows + a { & .b { .a & { ... though not sure why you would want to do that
|
|
610
|
-
var combinator = replacedElement.combinator, parentEl = addPath[0].elements[0];
|
|
611
|
-
if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) {
|
|
612
|
-
combinator = parentEl.combinator;
|
|
613
|
-
}
|
|
614
|
-
// join the elements so far with the first part of the parent
|
|
615
|
-
newJoinedSelector.elements.push(new Element(combinator, parentEl.value, replacedElement.index, replacedElement.currentFileInfo));
|
|
616
|
-
newJoinedSelector.elements = newJoinedSelector.elements.concat(addPath[0].elements.slice(1));
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
// now add the joined selector - but only if it is not empty
|
|
620
|
-
if (newJoinedSelector.elements.length !== 0) {
|
|
621
|
-
newSelectorPath.push(newJoinedSelector);
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
//put together the parent selectors after the join (e.g. the rest of the parent)
|
|
625
|
-
if (addPath.length > 1) {
|
|
626
|
-
var restOfPath = addPath.slice(1);
|
|
627
|
-
restOfPath = restOfPath.map(function (selector) {
|
|
628
|
-
return selector.createDerived(selector.elements, []);
|
|
629
|
-
});
|
|
630
|
-
newSelectorPath = newSelectorPath.concat(restOfPath);
|
|
631
|
-
}
|
|
632
|
-
return newSelectorPath;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
// joins selector path from `beginningPath` with every selector path in `addPaths` array
|
|
636
|
-
// `replacedElement` contains element that is being replaced by `addPath`
|
|
637
|
-
// returns array with all concatenated paths
|
|
638
|
-
function addAllReplacementsIntoPath( beginningPath, addPaths, replacedElement, originalSelector, result) {
|
|
639
|
-
var j;
|
|
640
|
-
for (j = 0; j < beginningPath.length; j++) {
|
|
641
|
-
var newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector);
|
|
642
|
-
result.push(newSelectorPath);
|
|
643
|
-
}
|
|
644
|
-
return result;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
function mergeElementsOnToSelectors(elements, selectors) {
|
|
648
|
-
var i, sel;
|
|
649
|
-
|
|
650
|
-
if (elements.length === 0) {
|
|
651
|
-
return ;
|
|
652
|
-
}
|
|
653
|
-
if (selectors.length === 0) {
|
|
654
|
-
selectors.push([ new Selector(elements) ]);
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
for (i = 0; i < selectors.length; i++) {
|
|
659
|
-
sel = selectors[i];
|
|
660
|
-
|
|
661
|
-
// if the previous thing in sel is a parent this needs to join on to it
|
|
662
|
-
if (sel.length > 0) {
|
|
663
|
-
sel[sel.length - 1] = sel[sel.length - 1].createDerived(sel[sel.length - 1].elements.concat(elements));
|
|
664
|
-
}
|
|
665
|
-
else {
|
|
666
|
-
sel.push(new Selector(elements));
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
|
|
671
671
|
function deriveSelector(visibilityInfo, deriveFrom) {
|
|
672
672
|
var newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition);
|
|
673
673
|
newSelector.copyVisibilityInfo(visibilityInfo);
|
package/lib/less/tree/unit.js
CHANGED
|
@@ -61,7 +61,7 @@ Unit.prototype.map = function(callback) {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
Unit.prototype.usedUnits = function() {
|
|
64
|
-
var group, result = {}, mapUnit;
|
|
64
|
+
var group, result = {}, mapUnit, groupName;
|
|
65
65
|
|
|
66
66
|
mapUnit = function (atomicUnit) {
|
|
67
67
|
/*jshint loopfunc:true */
|
|
@@ -72,7 +72,7 @@ Unit.prototype.usedUnits = function() {
|
|
|
72
72
|
return atomicUnit;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
for (
|
|
75
|
+
for (groupName in unitConversions) {
|
|
76
76
|
if (unitConversions.hasOwnProperty(groupName)) {
|
|
77
77
|
group = unitConversions[groupName];
|
|
78
78
|
|
|
@@ -104,16 +104,6 @@ module.exports = function(window, less, options) {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function error(e, rootHref) {
|
|
108
|
-
if (!options.errorReporting || options.errorReporting === "html") {
|
|
109
|
-
errorHTML(e, rootHref);
|
|
110
|
-
} else if (options.errorReporting === "console") {
|
|
111
|
-
errorConsole(e, rootHref);
|
|
112
|
-
} else if (typeof options.errorReporting === 'function') {
|
|
113
|
-
options.errorReporting("add", e, rootHref);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
107
|
function removeErrorHTML(path) {
|
|
118
108
|
var node = window.document.getElementById('less-error-message:' + utils.extractId(path));
|
|
119
109
|
if (node) {
|
|
@@ -163,6 +153,16 @@ module.exports = function(window, less, options) {
|
|
|
163
153
|
less.logger.error(content);
|
|
164
154
|
}
|
|
165
155
|
|
|
156
|
+
function error(e, rootHref) {
|
|
157
|
+
if (!options.errorReporting || options.errorReporting === "html") {
|
|
158
|
+
errorHTML(e, rootHref);
|
|
159
|
+
} else if (options.errorReporting === "console") {
|
|
160
|
+
errorConsole(e, rootHref);
|
|
161
|
+
} else if (typeof options.errorReporting === 'function') {
|
|
162
|
+
options.errorReporting("add", e, rootHref);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
166
|
return {
|
|
167
167
|
add: error,
|
|
168
168
|
remove: removeError
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "less",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Leaner CSS",
|
|
5
5
|
"homepage": "http://lesscss.org",
|
|
6
6
|
"author": {
|
|
@@ -37,29 +37,29 @@
|
|
|
37
37
|
},
|
|
38
38
|
"optionalDependencies": {
|
|
39
39
|
"errno": "^0.1.1",
|
|
40
|
-
"graceful-fs": "^
|
|
41
|
-
"image-size": "~0.
|
|
40
|
+
"graceful-fs": "^4.1.2",
|
|
41
|
+
"image-size": "~0.4.0",
|
|
42
42
|
"mime": "^1.2.11",
|
|
43
43
|
"mkdirp": "^0.5.0",
|
|
44
|
-
"promise": "^
|
|
44
|
+
"promise": "^7.1.1",
|
|
45
45
|
"request": "^2.51.0",
|
|
46
|
-
"source-map": "^0.
|
|
46
|
+
"source-map": "^0.5.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"diff": "^1
|
|
49
|
+
"diff": "^2.2.1",
|
|
50
50
|
"grunt": "^0.4.5",
|
|
51
|
-
"grunt-
|
|
52
|
-
"grunt-contrib-
|
|
53
|
-
"grunt-contrib-
|
|
54
|
-
"grunt-contrib-
|
|
55
|
-
"grunt-contrib-
|
|
56
|
-
"grunt-contrib-
|
|
57
|
-
"grunt-
|
|
58
|
-
"grunt-jscs": "^1.6.0",
|
|
59
|
-
"grunt-saucelabs": "^8.3.2",
|
|
51
|
+
"grunt-contrib-clean": "^1.0.0",
|
|
52
|
+
"grunt-contrib-concat": "^1.0.0",
|
|
53
|
+
"grunt-contrib-connect": "^0.11.2",
|
|
54
|
+
"grunt-contrib-jasmine": "^1.0.0",
|
|
55
|
+
"grunt-contrib-jshint": "^1.0.0",
|
|
56
|
+
"grunt-contrib-uglify": "^0.11.0",
|
|
57
|
+
"grunt-jscs": "^2.7.0",
|
|
60
58
|
"grunt-shell": "^1.1.1",
|
|
59
|
+
"grunt-browserify": "~4.0.1",
|
|
61
60
|
"jit-grunt": "^0.9.1",
|
|
62
|
-
"time-grunt": "^1.0.0"
|
|
61
|
+
"time-grunt": "^1.0.0",
|
|
62
|
+
"grunt-saucelabs": "^8.3.2"
|
|
63
63
|
},
|
|
64
64
|
"keywords": [
|
|
65
65
|
"compile less",
|