Skip to content

Commit

Permalink
beta 2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeapage committed Mar 18, 2013
1 parent b2d75e8 commit 2e0afb4
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- lessc `@import` supports https and 301's
- lessc "-depends" option for lessc writes out the list of import files used in makefile format
- lessc "-lint" option just reports errors
- support for namespaces in attributes and selector interpolation in attributes
- other bug fixes

# 1.3.3
Expand Down
83 changes: 59 additions & 24 deletions dist/less-1.4.0-beta.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,8 @@ less.Parser = function Parser(env) {
};

if (env.processImports !== false) {
try {
new tree.importVisitor(this.imports, finish)
.run(root);
}
catch(e) {
error = e;
}
new tree.importVisitor(this.imports, finish)
.run(root);
} else {
finish();
}
Expand Down Expand Up @@ -1282,16 +1277,17 @@ less.Parser = function Parser(env) {

if (! $('[')) return;

if (key = $(/^(?:[_A-Za-z0-9-]|\\.)+/) || $(this.entities.quoted)) {
if ((op = $(/^[|~*$^]?=/)) &&
(val = $(this.entities.quoted) || $(/^[\w-]+/))) {
attr = [key, op, val.toCSS ? val.toCSS() : val].join('');
} else { attr = key }
if (!(key = $(this.entities.variableCurly))) {
key = expect(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/);
}

if (! $(']')) return;
if ((op = $(/^[|~*$^]?=/))) {
val = $(this.entities.quoted) || $(/^[\w-]+/) || $(this.entities.variableCurly);
}

if (attr) { return "[" + attr + "]" }
expect(']');

return new(tree.Attribute)(key, op, val);
},

//
Expand Down Expand Up @@ -3149,6 +3145,32 @@ tree.Element.prototype = {
}
};

tree.Attribute = function (key, op, value) {
this.key = key;
this.op = op;
this.value = value;
};
tree.Attribute.prototype = {
type: "Attribute",
accept: function (visitor) {
this.value = visitor.visit(this.value);
},
eval: function (env) {
return new(tree.Attribute)(this.key.eval ? this.key.eval(env) : this.key,
this.op, (this.value && this.value.eval) ? this.value.eval(env) : this.value);
},
toCSS: function (env) {
var value = this.key.toCSS ? this.key.toCSS(env) : this.key;

if (this.op) {
value += this.op;
value += (this.value.toCSS ? this.value.toCSS(env) : this.value);
}

return '[' + value + ']';
}
};

tree.Combinator = function (value) {
if (value === ' ') {
this.value = ' ';
Expand Down Expand Up @@ -3968,9 +3990,16 @@ tree.Rule.prototype = {
toCSS: function (env) {
if (this.variable) { return "" }
else {
return this.name + (env.compress ? ':' : ': ') +
try {
return this.name + (env.compress ? ':' : ': ') +
this.value.toCSS(env) +
this.important + (this.inline ? "" : ";");
}
catch(e) {
e.index = this.index;
e.filename = this.currentFileInfo.filename;
throw e;
}
}
},
eval: function (env) {
Expand Down Expand Up @@ -4366,11 +4395,11 @@ tree.Ruleset.prototype = {
if (sel.length > 0) {
newSelectorPath = sel.slice(0);
lastSelector = newSelectorPath.pop();
newJoinedSelector = new(tree.Selector)(lastSelector.elements.slice(0));
newJoinedSelector = new(tree.Selector)(lastSelector.elements.slice(0), selector.extendList);
newJoinedSelectorEmpty = false;
}
else {
newJoinedSelector = new(tree.Selector)([]);
newJoinedSelector = new(tree.Selector)([], selector.extendList);
}

//put together the parent selectors after the join
Expand Down Expand Up @@ -4420,7 +4449,7 @@ tree.Ruleset.prototype = {
},

mergeElementsOnToSelectors: function(elements, selectors) {
var i, sel;
var i, sel, extendList;

if (selectors.length == 0) {
selectors.push([ new(tree.Selector)(elements) ]);
Expand All @@ -4432,7 +4461,7 @@ tree.Ruleset.prototype = {

// if the previous thing in sel is a parent this needs to join on to it
if (sel.length > 0) {
sel[sel.length - 1] = new(tree.Selector)(sel[sel.length - 1].elements.concat(elements));
sel[sel.length - 1] = new(tree.Selector)(sel[sel.length - 1].elements.concat(elements), sel[sel.length - 1].extendList);
}
else {
sel.push(new(tree.Selector)(elements));
Expand Down Expand Up @@ -4824,13 +4853,19 @@ tree.jsify = function (obj) {
tree.importVisitor.prototype = {
isReplacing: true,
run: function (root) {
// process the contents
this._visitor.visit(root);
var error;
try {
// process the contents
this._visitor.visit(root);
}
catch(e) {
error = e;
}

this.isFinished = true;

if (this.importCount === 0) {
this._finish();
this._finish(error);
}
},
visitImport: function (importNode, visitArgs) {
Expand All @@ -4857,11 +4892,11 @@ tree.jsify = function (obj) {
if (e && !e.filename) { e.index = importNode.index; e.filename = importNode.currentFileInfo.filename; }
if (imported && !importNode.options.multiple) { importNode.skip = imported; }

var subFinish = function() {
var subFinish = function(e) {
importVisitor.importCount--;

if (importVisitor.importCount === 0 && importVisitor.isFinished) {
importVisitor._finish();
importVisitor._finish(e);
}
};

Expand Down
8 changes: 4 additions & 4 deletions dist/less-1.4.0-beta.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/less/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var path = require('path'),
fs = require('fs');

var less = {
version: [1, 4, '0-b1'],
version: [1, 4, '0-b2'],
Parser: require('./parser').Parser,
importer: require('./parser').importer,
tree: require('./tree'),
Expand Down
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": "1.4.0-b1",
"version": "1.4.0-b2",
"description": "Leaner CSS",
"homepage": "http://lesscss.org",
"author": "Alexis Sellier <[email protected]>",
Expand Down

0 comments on commit 2e0afb4

Please sign in to comment.