Skip to content

Commit f4e1faf

Browse files
committed
1.5.1 release
1 parent ef4c2b7 commit f4e1faf

File tree

7 files changed

+116
-51
lines changed

7 files changed

+116
-51
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# 1.5.1
2+
3+
2013-11-17
4+
5+
- Added source-map-URL option
6+
- Fixed a bug which meant the minimised 1.5.0 browser version was not wrapped, meaning it interfered with require js
7+
- Fixed a bug where the browser version assume port was specified
8+
- Added the ability to specify variables on the command line
9+
- Upgraded clean-css and fixed it from trying to import
10+
- correct a bug meaning imports weren't synchronous (syncImport option available for full synchronous behaviour)
11+
- better mixin matching behaviour with calling multiple classes e.g. .a.b.c;
12+
113
# 1.5.0
214

315
2013-10-21

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [Less.js v1.5.0](http://lesscss.org)
1+
# [Less.js v1.5.1](http://lesscss.org)
22

33
> The **dynamic** stylesheet language. [http://lesscss.org](http://lesscss.org).
44

dist/less-1.5.0-b4.min.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

dist/less-1.5.0-b4.js renamed to dist/less-1.5.1.js

Lines changed: 84 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* LESS - Leaner CSS v1.5.0-b4
2+
* LESS - Leaner CSS v1.5.1
33
* http://lesscss.org
44
*
55
* Copyright (c) 2009-2013, Alexis Sellier <[email protected]>
@@ -73,7 +73,8 @@ less.Parser = function Parser(env) {
7373
furthest, // furthest index the parser has gone to
7474
chunks, // chunkified input
7575
current, // index of current chunk, in `input`
76-
parser;
76+
parser,
77+
rootFilename = env && env.filename;
7778

7879
// Top parser on an import tree must be sure there is one "env"
7980
// which will then be passed around by reference.
@@ -95,7 +96,7 @@ less.Parser = function Parser(env) {
9596
var fileParsedFunc = function (e, root, fullPath) {
9697
parserImports.queue.splice(parserImports.queue.indexOf(path), 1); // Remove the path from the queue
9798

98-
var importedPreviously = fullPath in parserImports.files;
99+
var importedPreviously = fullPath in parserImports.files || fullPath === rootFilename;
99100

100101
parserImports.files[fullPath] = root; // Store the root
101102

@@ -493,6 +494,7 @@ less.Parser = function Parser(env) {
493494
rootNode: evaldRoot,
494495
contentsMap: parser.imports.contents,
495496
sourceMapFilename: options.sourceMapFilename,
497+
sourceMapURL: options.sourceMapURL,
496498
outputFilename: options.sourceMapOutputFilename,
497499
sourceMapBasepath: options.sourceMapBasepath,
498500
sourceMapRootpath: options.sourceMapRootpath,
@@ -510,7 +512,9 @@ less.Parser = function Parser(env) {
510512
}
511513

512514
if (options.cleancss && less.mode === 'node') {
513-
return require('clean-css').process(css);
515+
var CleanCSS = require('clean-css');
516+
//TODO would be nice for no advanced to be an option
517+
return new CleanCSS({keepSpecialComments: '*', processImport: false, noRebase: true, noAdvanced: true}).minify(css);
514518
} else if (options.compress) {
515519
return css.replace(/(^(\s)+)|((\s)+$)/g, "");
516520
} else {
@@ -1302,7 +1306,7 @@ less.Parser = function Parser(env) {
13021306
$(this.comments);
13031307
if (! $(',')) { break; }
13041308
if (s.condition) {
1305-
error("Guards are only currently allowed on a single selector");
1309+
error("Guards are only currently allowed on a single selector.");
13061310
}
13071311
$(this.comments);
13081312
}
@@ -1643,7 +1647,7 @@ less.Parser = function Parser(env) {
16431647
var a, b, index = i, condition;
16441648

16451649
if (a = $(this.condition)) {
1646-
while ($(',') && (b = $(this.condition))) {
1650+
while (peek(/^,\s*(not\s*)?\(/) && $(',') && (b = $(this.condition))) {
16471651
condition = new(tree.Condition)('or', condition || a, b, index);
16481652
}
16491653
return condition || a;
@@ -3624,9 +3628,16 @@ tree.Extend.prototype = {
36243628
},
36253629
findSelfSelectors: function (selectors) {
36263630
var selfElements = [],
3627-
i;
3631+
i,
3632+
selectorElements;
36283633

36293634
for(i = 0; i < selectors.length; i++) {
3635+
selectorElements = selectors[i].elements;
3636+
// duplicate the logic in genCSS function inside the selector node.
3637+
// future TODO - move both logics into the selector joiner visitor
3638+
if (i > 0 && selectorElements.length && selectorElements[0].combinator.value === "") {
3639+
selectorElements[0].combinator.value = ' ';
3640+
}
36303641
selfElements = selfElements.concat(selectors[i].elements);
36313642
}
36323643

@@ -4373,7 +4384,7 @@ tree.Quoted.prototype = {
43734384
var v = new(tree.Variable)('@' + name, that.index, that.currentFileInfo).eval(env, true);
43744385
return (v instanceof tree.Quoted) ? v.value : v.toCSS();
43754386
});
4376-
return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index);
4387+
return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index, this.currentFileInfo);
43774388
},
43784389
compare: function (x) {
43794390
if (!x.toCSS) {
@@ -4626,9 +4637,9 @@ tree.Ruleset.prototype = {
46264637
if (rule !== self) {
46274638
for (var j = 0; j < rule.selectors.length; j++) {
46284639
if (match = selector.match(rule.selectors[j])) {
4629-
if (selector.elements.length > rule.selectors[j].elements.length) {
4640+
if (selector.elements.length > match) {
46304641
Array.prototype.push.apply(rules, rule.find(
4631-
new(tree.Selector)(selector.elements.slice(1)), self));
4642+
new(tree.Selector)(selector.elements.slice(match)), self));
46324643
} else {
46334644
rules.push(rule);
46344645
}
@@ -4954,15 +4965,15 @@ tree.Selector.prototype = {
49544965
max = Math.min(len, olen);
49554966

49564967
if (olen === 0 || len < olen) {
4957-
return false;
4968+
return 0;
49584969
} else {
49594970
for (i = 0; i < max; i++) {
49604971
if (elements[i].value !== oelements[i].value) {
4961-
return false;
4972+
return 0;
49624973
}
49634974
}
49644975
}
4965-
return true;
4976+
return max; // return number of matched selectors
49664977
},
49674978
eval: function (env) {
49684979
var evaldCondition = this.condition && this.condition.eval(env);
@@ -5724,6 +5735,7 @@ tree.Variable.prototype = {
57245735
for(i = 0; i < rulesetNode.rules.length; i++) {
57255736
if (rulesetNode.rules[i] instanceof tree.Extend) {
57265737
allSelectorsExtendList.push(rulesetNode.rules[i]);
5738+
rulesetNode.extendOnEveryPath = true;
57275739
}
57285740
}
57295741

@@ -5907,7 +5919,7 @@ tree.Variable.prototype = {
59075919
selectorPath = rulesetNode.paths[pathIndex];
59085920

59095921
// extending extends happens initially, before the main pass
5910-
if (selectorPath[selectorPath.length-1].extendList.length) { continue; }
5922+
if (rulesetNode.extendOnEveryPath || selectorPath[selectorPath.length-1].extendList.length) { continue; }
59115923

59125924
matches = this.findMatch(allExtends[extendIndex], selectorPath);
59135925

@@ -6008,6 +6020,24 @@ tree.Variable.prototype = {
60086020
elementValue2 = elementValue2.value.value || elementValue2.value;
60096021
return elementValue1 === elementValue2;
60106022
}
6023+
elementValue1 = elementValue1.value;
6024+
elementValue2 = elementValue2.value;
6025+
if (elementValue1 instanceof tree.Selector) {
6026+
if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) {
6027+
return false;
6028+
}
6029+
for(var i = 0; i <elementValue1.elements.length; i++) {
6030+
if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) {
6031+
if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) {
6032+
return false;
6033+
}
6034+
}
6035+
if (!this.isElementValuesEqual(elementValue1.elements[i].value, elementValue2.elements[i].value)) {
6036+
return false;
6037+
}
6038+
}
6039+
return true;
6040+
}
60116041
return false;
60126042
},
60136043
extendSelector:function (matches, selectorPath, replacementSelector) {
@@ -6064,7 +6094,6 @@ tree.Variable.prototype = {
60646094

60656095
if (currentSelectorPathIndex < selectorPath.length && currentSelectorPathElementIndex > 0) {
60666096
path[path.length - 1].elements = path[path.length - 1].elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex));
6067-
currentSelectorPathElementIndex = 0;
60686097
currentSelectorPathIndex++;
60696098
}
60706099

@@ -6103,6 +6132,7 @@ tree.Variable.prototype = {
61036132
this._contentsMap = options.contentsMap;
61046133
this._sourceMapFilename = options.sourceMapFilename;
61056134
this._outputFilename = options.outputFilename;
6135+
this._sourceMapURL = options.sourceMapURL;
61066136
this._sourceMapBasepath = options.sourceMapBasepath;
61076137
this._sourceMapRootpath = options.sourceMapRootpath;
61086138
this._outputSourceFiles = options.outputSourceFiles;
@@ -6188,21 +6218,23 @@ tree.Variable.prototype = {
61886218
this._rootNode.genCSS(env, this);
61896219

61906220
if (this._css.length > 0) {
6191-
var sourceMapFilename,
6221+
var sourceMapURL,
61926222
sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON());
61936223

6194-
if (this._sourceMapFilename) {
6195-
sourceMapFilename = this.normalizeFilename(this._sourceMapFilename);
6224+
if (this._sourceMapURL) {
6225+
sourceMapURL = this._sourceMapURL;
6226+
} else if (this._sourceMapFilename) {
6227+
sourceMapURL = this.normalizeFilename(this._sourceMapFilename);
61966228
}
61976229

61986230
if (this._writeSourceMap) {
61996231
this._writeSourceMap(sourceMapContent);
62006232
} else {
6201-
sourceMapFilename = "data:application/json," + encodeURIComponent(sourceMapContent);
6233+
sourceMapURL = "data:application/json," + encodeURIComponent(sourceMapContent);
62026234
}
62036235

6204-
if (sourceMapFilename) {
6205-
this._css.push("/*# sourceMappingURL=" + sourceMapFilename + " */");
6236+
if (sourceMapURL) {
6237+
this._css.push("/*# sourceMappingURL=" + sourceMapURL + " */");
62066238
}
62076239
}
62086240

@@ -6221,7 +6253,8 @@ var isFileProtocol = /^(file|chrome(-extension)?|resource|qrc|app):/.test(locati
62216253
less.env = less.env || (location.hostname == '127.0.0.1' ||
62226254
location.hostname == '0.0.0.0' ||
62236255
location.hostname == 'localhost' ||
6224-
location.port.length > 0 ||
6256+
(location.port &&
6257+
location.port.length > 0) ||
62256258
isFileProtocol ? 'development'
62266259
: 'production');
62276260

@@ -6265,6 +6298,7 @@ if (dumpLineNumbers) {
62656298
var typePattern = /^text\/(x-)?less$/;
62666299
var cache = null;
62676300
var fileCache = {};
6301+
var varsPre = "";
62686302

62696303
function log(str, level) {
62706304
if (less.env == 'development' && typeof(console) !== 'undefined' && less.logLevel >= level) {
@@ -6507,9 +6541,15 @@ function loadStyles(newVars) {
65076541
var env = new less.tree.parseEnv(less),
65086542
lessText = style.innerHTML || '';
65096543
env.filename = document.location.href.replace(/#.*$/, '');
6510-
if (newVars) {
6544+
6545+
if (newVars || varsPre) {
65116546
env.useFileCache = true;
6512-
lessText += "\n" + newVars;
6547+
6548+
lessText = varsPre + lessText;
6549+
6550+
if (newVars) {
6551+
lessText += "\n" + newVars;
6552+
}
65136553
}
65146554

65156555
/*jshint loopfunc:true */
@@ -6712,6 +6752,8 @@ function loadFile(originalHref, currentFileInfo, callback, env, newVars) {
67126752
}
67136753

67146754
doXHR(href, env.mime, function (data, lastModified) {
6755+
data = varsPre + data;
6756+
67156757
// per file cache
67166758
fileCache[href] = data;
67176759

@@ -6731,7 +6773,7 @@ function loadStyleSheet(sheet, callback, reload, remaining, newVars) {
67316773
var env = new less.tree.parseEnv(less);
67326774
env.mime = sheet.type;
67336775

6734-
if (newVars) {
6776+
if (newVars || varsPre) {
67356777
env.useFileCache = true;
67366778
}
67376779

@@ -6798,6 +6840,18 @@ function initRunningMode(){
67986840
}
67996841
}
68006842

6843+
function serializeVars(vars) {
6844+
var s = "";
6845+
6846+
for (var name in vars) {
6847+
s += ((name.slice(0,1) === '@')? '' : '@') + name +': '+
6848+
((vars[name].slice(-1) === ';')? vars[name] : vars[name] +';');
6849+
}
6850+
6851+
return s;
6852+
}
6853+
6854+
68016855
//
68026856
// Watch mode
68036857
//
@@ -6840,12 +6894,7 @@ for (var i = 0; i < links.length; i++) {
68406894
// CSS without reloading less-files
68416895
//
68426896
less.modifyVars = function(record) {
6843-
var newVars = "";
6844-
for (var name in record) {
6845-
newVars += ((name.slice(0,1) === '@')? '' : '@') + name +': '+
6846-
((record[name].slice(-1) === ';')? record[name] : record[name] +';');
6847-
}
6848-
less.refresh(false, newVars);
6897+
less.refresh(false, serializeVars(record));
68496898
};
68506899

68516900
less.refresh = function (reload, newVars) {
@@ -6872,6 +6921,10 @@ less.refresh = function (reload, newVars) {
68726921
loadStyles(newVars);
68736922
};
68746923

6924+
if (less.globalVars) {
6925+
varsPre = serializeVars(less.globalVars) + "\n";
6926+
}
6927+
68756928
less.refreshStyles = loadStyles;
68766929

68776930
less.Parser.fileLoader = loadFile;

dist/less-1.5.1.min.js

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

lib/less/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var path = require('path'),
44
fs = require('fs');
55

66
var less = {
7-
version: [1, 5, 0],
7+
version: [1, 5, 1],
88
Parser: require('./parser').Parser,
99
tree: require('./tree'),
1010
render: function (input, options, callback) {

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "less",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "Leaner CSS",
55
"homepage": "http://lesscss.org",
66
"author": {
@@ -42,7 +42,7 @@
4242
"optionalDependencies": {
4343
"mime": "1.2.x",
4444
"request": ">=2.12.0",
45-
"mkdirp": "~0.3.4",
45+
"mkdirp": "~0.3.5",
4646
"clean-css": "2.0.x",
4747
"source-map": "0.1.x"
4848
},
@@ -52,9 +52,9 @@
5252
"grunt-contrib-clean": "~0.5.0",
5353
"grunt-contrib-concat": "~0.3.0",
5454
"grunt-contrib-connect": "~0.3.0",
55-
"grunt-contrib-jasmine": "~0.5.1",
56-
"grunt-contrib-jshint": "~0.6.0",
57-
"grunt-contrib-uglify": "~0.2.2",
55+
"grunt-contrib-jasmine": "~0.5.2",
56+
"grunt-contrib-jshint": "~0.7.2",
57+
"grunt-contrib-uglify": "~0.2.7",
5858
"grunt-shell": "~0.3.1",
5959
"http-server": "~0.5.5",
6060
"matchdep": "~0.1.2",

0 commit comments

Comments
 (0)