8000 1.5.0 beta 3 release · rback/less.js@ee11dfb · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit ee11dfb

Browse files
committed
1.5.0 beta 3 release
1 parent 40cd226 commit ee11dfb

File tree

6 files changed

+91
-44
lines changed

6 files changed

+91
-44
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# 1.5.0 Beta 1
1+
# 1.5.0 Beta 3
22

3-
2013-09-01
3+
2013-09-17
44

55
- sourcemap support
66
- support for import inline option to include css that you do NOT want less to parse e.g. `@import (inline) "file.css";`
@@ -16,9 +16,12 @@
1616
- Added svg-gradient function
1717
- Added no-js option to lessc (in browser, use javascriptEnabled: false) which disallows JavaScript in less files
1818
- switched from the little supported and buggy cssmin (previously ycssmin) to clean-css
19+
- support transparent as a color, but not convert between rgba(0, 0, 0, 0) and transparent
20+
- remove sys.puts calls to stop deprecation warnings in future node.js releases
1921
- Browser: added logLevel option to control logging (2 = everything, 1 = errors only, 0 = no logging)
2022
- Browser: added errorReporting option which can be "html" (default) or "console" or a function
21-
- A few bug fixes for media queries and extends
23+
- Now uses grunt for building and testing
24+
- A few bug fixes for media queries, extends, scoping, compression
2225

2326
# 1.4.2
2427

dist/less-1.5.0-b2.min.js

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

dist/less-1.5.0-b2.js renamed to dist/less-1.5.0-b3.js

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/*
2-
* LESS - Leaner CSS v1.5.0-b2
1+
/*!
2+
* LESS - Leaner CSS v1.5.0-b3
33
* http://lesscss.org
44
*
55
* Copyright (c) 2009-2013, Alexis Sellier <self@cloudhead.net>
@@ -496,7 +496,8 @@ less.Parser = function Parser(env) {
496496
outputFilename: options.sourceMapOutputFilename,
497497
sourceMapBasepath: options.sourceMapBasepath,
498498
sourceMapRootpath: options.sourceMapRootpath,
499-
outputSourceFiles: options.outputSourceFiles
499+
outputSourceFiles: options.outputSourceFiles,
500+
sourceMapGenerator: options.sourceMapGenerator
500501
});
501502
}
502503

@@ -555,18 +556,18 @@ less.Parser = function Parser(env) {
555556
e = new(LessError)(e, env);
556557
}
557558

558-
callback(e);
559+
return callback(e);
559560
}
560561
else {
561-
callback(null, root);
562+
return callback(null, root);
562563
}
563564
};
564565

565566
if (env.processImports !== false) {
566567
new tree.importVisitor(this.imports, finish)
567568
.run(root);
568569
} else {
569-
finish();
570+
return finish();
570571
}
571572
},
572573

@@ -682,12 +683,11 @@ less.Parser = function Parser(env) {
682683
var k;
683684

684685
if (k = $(/^[_A-Za-z-][_A-Za-z0-9-]*/)) {
685-
if (tree.colors.hasOwnProperty(k)) {
686-
// detect named color
687-
F438 return new(tree.Color)(tree.colors[k].slice(1));
688-
} else {
689-
return new(tree.Keyword)(k);
686+
var color = tree.Color.fromKeyword(k);
687+
if (color) {
688+
return color;
690689
}
690+
return new(tree.Keyword)(k);
691691
}
692692
},
693693

@@ -1491,7 +1491,7 @@ less.Parser = function Parser(env) {
14911491
//
14921492
directive: function () {
14931493
var name, value, rules, nonVendorSpecificName,
1494-
hasBlock, hasIdentifier, hasExpression;
1494+
hasBlock, hasIdentifier, hasExpression, identifier;
14951495

14961496
if (input.charAt(i) !== '@') { return; }
14971497

@@ -1546,7 +1546,10 @@ less.Parser = function Parser(env) {
15461546
}
15471547

15481548
if (hasIdentifier) {
1549-
name += " " + ($(/^[^{]+/) || '').trim();
1549+
identifier = ($(/^[^{]+/) || '').trim();
1550+
if (identifier) {
1551+
name += " " + identifier;
1552+
}
15501553
}
15511554

15521555
if (hasBlock)
@@ -2047,7 +2050,16 @@ tree.functions = {
20472050
},
20482051
color: function (n) {
20492052
if (n instanceof tree.Quoted) {
2050-
return new(tree.Color)(n.value.slice(1));
2053+
var colorCandidate = n.value,
2054+
returnColor;
2055+
returnColor = tree.Color.fromKeyword(colorCandidate);
2056+
if (returnColor) {
2057+
return returnColor;
2058+
}
2059+
if (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/.test(colorCandidate)) {
2060+
return new(tree.Color)(colorCandidate.slice(1));
2061+
}
2062+
throw { type: "Argument", message: "argument must be a color keyword or 3/6 digit hex e.g. #FFF" };
20512063
} else {
20522064
throw { type: "Argument", message: "argument must be a string" };
20532065
}
@@ -2528,7 +2540,6 @@ tree.functionCall.prototype = tree.functions;
25282540
'teal':'#008080',
25292541
'thistle':'#d8bfd8',
25302542
'tomato':'#ff6347',
2531-
// 'transparent':'rgba(0,0,0,0)',
25322543
'turquoise':'#40e0d0',
25332544
'violet':'#ee82ee',
25342545
'wheat':'#f5deb3',
@@ -2803,6 +2814,9 @@ tree.Color = function (rgb, a) {
28032814
}
28042815
this.alpha = typeof(a) === 'number' ? a : 1;
28052816
};
2817+
2818+
var transparentKeyword = "transparent";
2819+
28062820
tree.Color.prototype = {
28072821
type: "Color",
28082822
eval: function () { return this; },
@@ -2819,6 +2833,9 @@ tree.Color.prototype = {
28192833
// which has better compatibility with older browsers.
28202834
// Values are capped between `0` and `255`, rounded and zero-padded.
28212835
if (this.alpha < 1.0) {
2836+
if (this.alpha === 0 && this.isTransparentKeyword) {
2837+
return transparentKeyword;
2838+
}
28222839
return "rgba(" + this.rgb.map(function (c) {
28232840
return Math.round(c);
28242841
}).concat(this.alpha).join(',' + (compress ? '' : ' ')) + ")";
@@ -2937,6 +2954,18 @@ tree.Color.prototype = {
29372954
}
29382955
};
29392956

2957+
tree.Color.fromKeyword = function(keyword) {
2958+
if (tree.colors.hasOwnProperty(keyword)) {
2959+
// detect named color
2960+
return new(tree.Color)(tree.colors[keyword].slice(1));
2961+
}
2962+
if (keyword === transparentKeyword) {
2963+
var transparent = new(tree.Color)([0, 0, 0], 0);
2964+
transparent.isTransparentKeyword = true;
2965+
return transparent;
2966+
}
2967+
};
2968+
29402969

29412970
})(require('../tree'));
29422971

@@ -4150,11 +4179,11 @@ tree.mixin.Definition.prototype = {
41504179
return ruleset;
41514180
},
41524181
matchCondition: function (args, env) {
4153-
41544182
if (this.condition && !this.condition.eval(
41554183
new(tree.evalEnv)(env,
4156-
[this.evalParams(env, new(tree.evalEnv)(env, this.frames.concat(env.frames)), args, [])]
4157-
.concat(env.frames)))) {
4184+
[this.evalParams(env, new(tree.evalEnv)(env, this.frames.concat(env.frames)), args, [])] // the parameter variables
4185+
.concat(this.frames) // the parent namespace/mixin frames
4186+
.concat(env.frames)))) { // the current environment frames
41584187
return false;
41594188
}
41604189
return true;
@@ -4644,7 +4673,9 @@ tree.Ruleset.prototype = {
46444673
for (i = 0; i < ruleNodes.length; i++) {
46454674
rule = ruleNodes[i];
46464675

4647-
if (i + 1 === ruleNodes.length) {
4676+
// @page{ directive ends up with root elements inside it, a mix of rules and rulesets
4677+
// In this instance we do not know whether it is the last property
4678+
if (i + 1 === ruleNodes.length && (!this.root || rulesetNodes.length === 0 || this.firstRoot)) {
46484679
env.lastRule = true;
46494680
}
46504681

@@ -4668,10 +4699,10 @@ tree.Ruleset.prototype = {
46684699

46694700
for (i = 0; i < rulesetNodes.length; i++) {
46704701
if (ruleNodes.length && firstRuleset) {
4671-
output.add("\n" + (this.root ? tabRuleStr : tabSetStr));
4702+
output.add((env.compress ? "" : "\n") + (this.root ? tabRuleStr : tabSetStr));
46724703
}
46734704
if (!firstRuleset) {
4674-
output.add('\n' + (this.root ? tabRuleStr : tabSetStr));
4705+
output.add((env.compress ? "" : "\n") + (this.root ? tabRuleStr : tabSetStr));
46754706
}
46764707
firstRuleset = false;
46774708
rulesetNodes[i].genCSS(env, output);
@@ -5087,6 +5118,7 @@ tree.Variable.prototype = {
50875118
'relativeUrls', // option - whether to adjust URL's to be relative
50885119
'rootpath', // option - rootpath to append to URL's
50895120
'strictImports', // option -
5121+
'insecure', // option - whether to allow imports from insecure ssl hosts
50905122
'dumpLineNumbers', // option - whether to dump line numbers
50915123
'compress', // option - whether to compress
50925124
'processImports', // option - whether to process imports. if false then imports will not be imported
@@ -6034,7 +6066,6 @@ tree.Variable.prototype = {
60346066
})(require('./tree'));
60356067

60366068
(function (tree) {
6037-
var sourceMap = require("source-map");
60386069

60396070
tree.sourceMapOutput = function (options) {
60406071
this._css = [];
@@ -6046,6 +6077,7 @@ tree.Variable.prototype = {
60466077
this._sourceMapBasepath = options.sourceMapBasepath;
60476078
this._sourceMapRootpath = options.sourceMapRootpath;
60486079
this._outputSourceFiles = options.outputSourceFiles;
6080+
this._sourceMapGeneratorConstructor = options.sourceMapGenerator || require("source-map").SourceMapGenerator;
60496081

60506082
if (this._sourceMapRootpath && this._sourceMapRootpath.charAt(this._sourceMapRootpath.length-1) !== '/') {
60516083
this._sourceMapRootpath += '/';
@@ -6062,7 +6094,7 @@ tree.Variable.prototype = {
60626094
filename = filename.substring(1);
60636095
}
60646096
}
6065-
return this._sourceMapRootpath + filename.replace(/\\/g, '/');
6097+
return (this._sourceMapRootpath || "") + filename.replace(/\\/g, '/');
60666098
};
60676099

60686100
tree.sourceMapOutput.prototype.add = function(chunk, fileInfo, index) {
@@ -6101,7 +6133,7 @@ tree.Variable.prototype = {
61016133
};
61026134

61036135
tree.sourceMapOutput.prototype.toCSS = function(env) {
6104-
this._sourceMapGenerator = new sourceMap.SourceMapGenerator({ file: this._outputFilename, sourceRoot: null });
6136+
this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null });
61056137

61066138
if (this._outputSourceFiles) {
61076139
for(var filename in this._contentsMap) {
@@ -6112,17 +6144,29 @@ tree.Variable.prototype = {
61126144
this._rootNode.genCSS(env, this);
61136145

61146146
if (this._css.length > 0) {
6115-
this._writeSourceMap(JSON.stringify(this._sourceMapGenerator.toJSON()));
6147+
var sourceMapFilename,
6148+
sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON());
61166149

61176150
if (this._sourceMapFilename) {
6118-
this._css.push("/*# sourceMappingURL=" + this._sourceMapRootpath + this._sourceMapFilename + " */");
6151+
sourceMapFilename = this.normalizeFilename(this._sourceMapFilename);
6152+
}
6153+
6154+
if (this._writeSourceMap) {
6155+
this._writeSourceMap(sourceMapContent);
6156+
} else {
6157+
sourceMapFilename = "data:application/json," + encodeURIComponent(sourceMapContent);
6158+
}
6159+
6160+
if (sourceMapFilename) {
6161+
this._css.push("/*# sourceMappingURL=" + sourceMapFilename + " */");
61196162
}
61206163
}
61216164

61226165
return this._css.join('');
61236166
};
61246167

61256168
})(require('./tree'));
6169+
61266170
//
61276171
// browser.js - client-side engine
61286172
//

dist/less-1.5.0-b3.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
@@ -5,7 +5,7 @@ var path = require('path'),
55
fs = require('fs');
66

77
var less = {
8-
version: [1, 5, "0-b2"],
8+
version: [1, 5, "0-b3"],
99
Parser: require('./parser').Parser,
1010
tree: require('./tree'),
1111
render: function (input, options, callback) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "less",
3-
"version": "1.5.0-b2",
3+
"version": "1.5.0-b3",
44
"description": "Leaner CSS",
55
"homepage": "http://lesscss.org",
66
"author": {

0 commit comments

Comments
 (0)
0