Skip to content

Commit 327b5d5

Browse files
committed
Merge branch '3.x' into edge
# Conflicts: # package.json
2 parents 3642ca9 + 367b46a commit 327b5d5

File tree

10 files changed

+160
-183
lines changed

10 files changed

+160
-183
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
# 3.0.0
2+
2018-02-04
3+
- Rename Directive -> AtRule & Rule -> Declaration
4+
- Cross-platform `@plugin` loading! (Node & Browser)
5+
- Numerous changes / improvements to plugin architecture
6+
- Simplified API calls in plugins (`less.atrule()` vs `new less.tree.AtRule()`)
7+
- Property accessors (`$width` to refer to `width: 300px` value)
8+
- Inline JavaScript disabled by default for security reasons (use `@plugin`)
9+
- Improvements in Less error reporting
10+
- Added feature: returning `null` / `false` from Less functions will remove that line
11+
- Simple `boolean()` and `if()` functions added
12+
- Bug fixes
13+
- Removal of unnecessary nodes from API (like IE's `alpha()`)
14+
15+
# 2.7.3
16+
2017-10-23
17+
18+
- Bump `request` dependency
19+
20+
# 2.7.2
21+
2017-01-04
22+
23+
- Revert breaking changes to contrast() function
24+
- Fix error reporting of lessc executable
25+
- Changed octals to hex for ES6 strict mode
26+
127
# 2.7.1 HOTFIX
228

329
2016-05-09

dist/less.js

Lines changed: 71 additions & 136 deletions
Large diffs are not rendered by default.

dist/less.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/less/parser/parser.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ var Parser = function Parser(context, imports, fileInfo) {
374374
// black border-collapse
375375
//
376376
keyword: function () {
377-
var k = parserInput.$char("%") || parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]*/);
377+
var k = parserInput.$char("%") || parserInput.$re(/^\[?[_A-Za-z-][_A-Za-z0-9-]*\]?/);
378378
if (k) {
379379
return tree.Color.fromKeyword(k) || new(tree.Keyword)(k);
380380
}
@@ -1316,6 +1316,35 @@ var Parser = function Parser(context, imports, fileInfo) {
13161316
parserInput.restore();
13171317
}
13181318
},
1319+
/**
1320+
* Will parse until regex, unless token is within {},(),[]
1321+
* Treat like a quoted value for variable interpolation
1322+
*
1323+
* @todo WIP for custom properties
1324+
*/
1325+
parseUntil: function(re) {
1326+
var str = '', e = '',
1327+
match, ch,
1328+
index = parserInput.i,
1329+
regex = new RegExp('^[^\{\(\[]+' + re);
1330+
1331+
do {
1332+
match = parserInput.$re(regex) || '';
1333+
ch = parserInput.currentChar();
1334+
if (ch === '{') {
1335+
e = parserInput.$re(/^[^\}]+\}/);
1336+
}
1337+
else if (ch === '(') {
1338+
e = parserInput.$re(/^[^\)]+\)/);
1339+
}
1340+
else if (ch === '[') {
1341+
e = parserInput.$re(/^[^\]]+\]/);
1342+
}
1343+
str += match + e;
1344+
} while (match);
1345+
1346+
return new(tree.Quoted)('', str.slice(0, -1), true, index, fileInfo);
1347+
},
13191348
anonymousValue: function () {
13201349
var index = parserInput.i;
13211350
var match = parserInput.$re(/^([^@\$+\/'"*`(;{}-]*);/);

lib/less/plugin-manager.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var utils = require('./utils');
21
/**
32
* Plugin Manager
43
*/
@@ -54,33 +53,12 @@ PluginManager.prototype.get = function(filename) {
5453
return this.pluginCache[filename];
5554
};
5655

57-
/**
58-
* Deprecate eventually
59-
*/
60-
function upgradeVisitors(visitor, oldType, newType) {
61-
62-
if (visitor['visit' + oldType] && !visitor['visit' + newType]) {
63-
visitor['visit' + newType] = visitor['visit' + oldType];
64-
}
65-
if (visitor['visit' + oldType + 'Out'] && !visitor['visit' + newType + 'Out']) {
66-
visitor['visit' + newType + 'Out'] = visitor['visit' + oldType + 'Out'];
67-
}
68-
}
6956
/**
7057
* Adds a visitor. The visitor object has options on itself to determine
7158
* when it should run.
7259
* @param visitor
7360
*/
7461
PluginManager.prototype.addVisitor = function(visitor) {
75-
var proto;
76-
// 2.x to 3.x visitor compatibility
77-
try {
78-
proto = utils.getPrototype(visitor);
79-
upgradeVisitors(proto, 'Directive', 'AtRule');
80-
upgradeVisitors(proto, 'Rule', 'Declaration');
81-
}
82-
catch (e) {}
83-
8462
this.visitors.push(visitor);
8563
};
8664
/**

lib/less/tree/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ var tree = Object.create(null);
33
tree.Node = require('./node');
44
tree.Color = require('./color');
55
tree.AtRule = require('./atrule');
6-
// Backwards compatibility
7-
tree.Directive = require('./directive');
86
tree.DetachedRuleset = require('./detached-ruleset');
97
tree.Operation = require('./operation');
108
tree.Dimension = require('./dimension');
@@ -20,8 +18,6 @@ tree.Selector = require('./selector');
2018
tree.Quoted = require('./quoted');
2119
tree.Expression = require('./expression');
2220
tree.Declaration = require('./declaration');
23-
// Backwards compatibility
24-
tree.Rule = require('./rule');
2521
tree.Call = require('./call');
2622
tree.URL = require('./url');
2723
tree.Import = require('./import');

lib/less/utils.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,5 @@ module.exports = {
6565
}
6666
}
6767
return obj1;
68-
},
69-
getPrototype: function(obj) {
70-
if (Object.getPrototypeOf) {
71-
return Object.getPrototypeOf(obj);
72-
}
73-
else {
74-
if ("".__proto__ === String.prototype) {
75-
return obj.__proto__;
76-
}
77-
else if (obj.constructor) {
78-
return obj.constructor.prototype;
79-
}
80-
}
8168
}
8269
};

test/css/css-grid.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.wrapper {
2+
display: grid;
3+
grid-template-columns: [col1-start] 9fr [col1-end] 10px [col2-start] 3fr [col2-end];
4+
grid-template-rows: auto;
5+
}
6+
.wrapper {
7+
display: grid;
8+
grid-template-columns: 9fr 1.875em 3fr;
9+
grid-template-rows: auto;
10+
grid-template-areas: "header header header" "content . sidebar" "footer footer footer";
11+
}

test/less/css-grid.less

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.wrapper {
2+
display: grid;
3+
grid-template-columns: [col1-start] 9fr [col1-end] 10px [col2-start] 3fr [col2-end];
4+
grid-template-rows: auto;
5+
}
6+
7+
.wrapper {
8+
display: grid;
9+
grid-template-columns: 9fr 1.875em 3fr;
10+
grid-template-rows: auto;
11+
grid-template-areas:
12+
"header header header"
13+
"content . sidebar"
14+
"footer footer footer";
15+
}

test/plugins/visitor/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
run: function (root) {
99
return this._visitor.visit(root);
1010
},
11-
visitRule: function (ruleNode, visitArgs) {
11+
visitDeclaration: function (ruleNode, visitArgs) {
1212
if (ruleNode.name != '-some-aribitrary-property') {
1313
return ruleNode;
1414
} else {

0 commit comments

Comments
 (0)