Skip to content

Commit

Permalink
Remove legacy upgrade
Browse files Browse the repository at this point in the history
- Add simple grid syntax support
  • Loading branch information
matthew-dean committed Feb 10, 2018
1 parent 2a4a63a commit 4508495
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 184 deletions.
207 changes: 71 additions & 136 deletions dist/less.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/less.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/less/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ var Parser = function Parser(context, imports, fileInfo) {
// black border-collapse
//
keyword: function () {
var k = parserInput.$char("%") || parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]*/);
var k = parserInput.$char("%") || parserInput.$re(/^\[?[_A-Za-z-][_A-Za-z0-9-]*\]?/);
if (k) {
return tree.Color.fromKeyword(k) || new(tree.Keyword)(k);
}
Expand Down
22 changes: 0 additions & 22 deletions lib/less/plugin-manager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var utils = require('./utils');
/**
* Plugin Manager
*/
Expand Down Expand Up @@ -54,33 +53,12 @@ PluginManager.prototype.get = function(filename) {
return this.pluginCache[filename];
};

/**
* Deprecate eventually
*/
function upgradeVisitors(visitor, oldType, newType) {

if (visitor['visit' + oldType] && !visitor['visit' + newType]) {
visitor['visit' + newType] = visitor['visit' + oldType];
}
if (visitor['visit' + oldType + 'Out'] && !visitor['visit' + newType + 'Out']) {
visitor['visit' + newType + 'Out'] = visitor['visit' + oldType + 'Out'];
}
}
/**
* Adds a visitor. The visitor object has options on itself to determine
* when it should run.
* @param visitor
*/
PluginManager.prototype.addVisitor = function(visitor) {
var proto;
// 2.x to 3.x visitor compatibility
try {
proto = utils.getPrototype(visitor);
upgradeVisitors(proto, 'Directive', 'AtRule');
upgradeVisitors(proto, 'Rule', 'Declaration');
}
catch (e) {}

this.visitors.push(visitor);
};
/**
Expand Down
4 changes: 0 additions & 4 deletions lib/less/tree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ var tree = Object.create(null);
tree.Node = require('./node');
tree.Color = require('./color');
tree.AtRule = require('./atrule');
// Backwards compatibility
tree.Directive = require('./directive');
tree.DetachedRuleset = require('./detached-ruleset');
tree.Operation = require('./operation');
tree.Dimension = require('./dimension');
Expand All @@ -20,8 +18,6 @@ tree.Selector = require('./selector');
tree.Quoted = require('./quoted');
tree.Expression = require('./expression');
tree.Declaration = require('./declaration');
// Backwards compatibility
tree.Rule = require('./rule');
tree.Call = require('./call');
tree.URL = require('./url');
tree.Import = require('./import');
Expand Down
13 changes: 0 additions & 13 deletions lib/less/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,5 @@ module.exports = {
}
}
return obj1;
},
getPrototype: function(obj) {
if (Object.getPrototypeOf) {
return Object.getPrototypeOf(obj);
}
else {
if ("".__proto__ === String.prototype) {
return obj.__proto__;
}
else if (obj.constructor) {
return obj.constructor.prototype;
}
}
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "less",
"version": "3.0.0-RC.1",
"version": "3.0.0-RC.2",
"description": "Leaner CSS",
"homepage": "http://lesscss.org",
"author": {
Expand Down
11 changes: 11 additions & 0 deletions test/css/css-grid.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.wrapper {
display: grid;
grid-template-columns: [col1-start] 9fr [col1-end] 10px [col2-start] 3fr [col2-end];
grid-template-rows: auto;
}
.wrapper {
display: grid;
grid-template-columns: 9fr 1.875em 3fr;
grid-template-rows: auto;
grid-template-areas: "header header header" "content . sidebar" "footer footer footer";
}
15 changes: 15 additions & 0 deletions test/less/css-grid.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.wrapper {
display: grid;
grid-template-columns: [col1-start] 9fr [col1-end] 10px [col2-start] 3fr [col2-end];
grid-template-rows: auto;
}

.wrapper {
display: grid;
grid-template-columns: 9fr 1.875em 3fr;
grid-template-rows: auto;
grid-template-areas:
"header header header"
"content . sidebar"
"footer footer footer";
}
2 changes: 1 addition & 1 deletion test/plugins/visitor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
run: function (root) {
return this._visitor.visit(root);
},
visitRule: function (ruleNode, visitArgs) {
visitDeclaration: function (ruleNode, visitArgs) {
if (ruleNode.name != '-some-aribitrary-property') {
return ruleNode;
} else {
Expand Down

0 comments on commit 4508495

Please sign in to comment.