Skip to content

Commit 0394212

Browse files
author
Nicholas C. Zakas
committed
Release v0.8.5
1 parent 8e1a35d commit 0394212

File tree

10 files changed

+433
-289
lines changed

10 files changed

+433
-289
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
November 15, 2011 - v0.8.5
2+
3+
* Updated parser (fixes #206 and fixes #209) (Nicholas C. Zakas)
4+
* Removed extra file (Nicholas C. Zakas)
5+
16
October 25, 2011 - v0.8.1
27

38
* Updated parser and fixed CLI errors (fixes #203 and fixes #205) (Nicholas C. Zakas)

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<project name="csslint" default="build.all">
22

33
<!-- version number -->
4-
<property name="csslint.version" value="0.8.1" />
4+
<property name="csslint.version" value="0.8.5" />
55

66
<!-- the directories containing the source files -->
77
<property name="src.dir" value="./src" />

release/csslint-node.js

Lines changed: 85 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
THE SOFTWARE.
2222
2323
*/
24-
/* Build time: 25-October-2011 09:25:06 */
25-
24+
/* Build time: 15-November-2011 07:33:18 */
2625
/*!
2726
Parser-Lib
2827
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -46,11 +45,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4645
THE SOFTWARE.
4746
4847
*/
49-
/* Build time: 25-October-2011 09:11:57 */
48+
/* Build time: 1-November-2011 12:11:55 */
5049
var parserlib = {};
5150
(function(){
5251

53-
5452
/**
5553
* A generic base to inherit from for any object
5654
* that needs event handling.
@@ -920,8 +918,6 @@ TokenStreamBase.prototype = {
920918
};
921919

922920

923-
924-
925921
parserlib.util = {
926922
StringReader: StringReader,
927923
SyntaxError : SyntaxError,
@@ -930,8 +926,6 @@ EventTarget : EventTarget,
930926
TokenStreamBase : TokenStreamBase
931927
};
932928
})();
933-
934-
935929
/*
936930
Parser-Lib
937931
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -955,15 +949,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
955949
THE SOFTWARE.
956950
957951
*/
958-
/* Build time: 25-October-2011 09:11:57 */
952+
/* Build time: 1-November-2011 12:11:55 */
959953
(function(){
960954
var EventTarget = parserlib.util.EventTarget,
961955
TokenStreamBase = parserlib.util.TokenStreamBase,
962956
StringReader = parserlib.util.StringReader,
963957
SyntaxError = parserlib.util.SyntaxError,
964958
SyntaxUnit = parserlib.util.SyntaxUnit;
965959

966-
967960
var Colors = {
968961
aliceblue :"#f0f8ff",
969962
antiquewhite :"#faebd7",
@@ -1143,7 +1136,6 @@ function Combinator(text, line, col){
11431136
Combinator.prototype = new SyntaxUnit();
11441137
Combinator.prototype.constructor = Combinator;
11451138

1146-
11471139
/**
11481140
* Represents a media feature, such as max-width:500.
11491141
* @namespace parserlib.css
@@ -1175,7 +1167,6 @@ function MediaFeature(name, value){
11751167
MediaFeature.prototype = new SyntaxUnit();
11761168
MediaFeature.prototype.constructor = MediaFeature;
11771169

1178-
11791170
/**
11801171
* Represents an individual media query.
11811172
* @namespace parserlib.css
@@ -1218,7 +1209,6 @@ function MediaQuery(modifier, mediaType, features, line, col){
12181209
MediaQuery.prototype = new SyntaxUnit();
12191210
MediaQuery.prototype.constructor = MediaQuery;
12201211

1221-
12221212
/**
12231213
* A CSS3 parser.
12241214
* @namespace parserlib.css
@@ -3396,12 +3386,22 @@ nth
33963386
['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
33973387
;
33983388
*/
3389+
//This file will likely change a lot! Very experimental!
3390+
33993391
var ValidationType = {
34003392

34013393
"absolute-size": function(part){
34023394
return this.identifier(part, "xx-small | x-small | small | medium | large | x-large | xx-large");
34033395
},
34043396

3397+
"attachment": function(part){
3398+
return this.identifier(part, "scroll | fixed | local");
3399+
},
3400+
3401+
"box": function(part){
3402+
return this.identifier(part, "padding-box | border-box | content-box");
3403+
},
3404+
34053405
"relative-size": function(part){
34063406
return this.identifier(part, "smaller | larger");
34073407
},
@@ -3449,6 +3449,10 @@ var ValidationType = {
34493449
return this.uri(part);
34503450
},
34513451

3452+
"bg-image": function(part){
3453+
return this.image(part) || part == "none";
3454+
},
3455+
34523456
"percentage": function(part){
34533457
return part.type == "percentage" || part == "0";
34543458
},
@@ -3483,25 +3487,25 @@ var Properties = {
34833487
"alignment-baseline": 1,
34843488
"animation": 1,
34853489
"animation-delay": 1,
3486-
"animation-direction": 1,
3490+
"animation-direction": { multi: [ "normal | alternate" ], separator: "," },
34873491
"animation-duration": 1,
34883492
"animation-fill-mode": 1,
3489-
"animation-iteration-count": 1,
3493+
"animation-iteration-count": { multi: [ "number", "infinite"], separator: "," },
34903494
"animation-name": 1,
3491-
"animation-play-state": 1,
3495+
"animation-play-state": { multi: [ "running | paused" ], separator: "," },
34923496
"animation-timing-function": 1,
34933497
"appearance": 1,
34943498
"azimuth": 1,
34953499

34963500
//B
34973501
"backface-visibility": 1,
34983502
"background": 1,
3499-
"background-attachment": [ "scroll | fixed | inherit" ],
3503+
"background-attachment": { multi: [ "attachment" ], separator: "," },
35003504
"background-break": 1,
3501-
"background-clip": 1,
3505+
"background-clip": { multi: [ "box" ], separator: "," },
35023506
"background-color": [ "color", "inherit" ],
3503-
"background-image": 1,
3504-
"background-origin": 1,
3507+
"background-image": { multi: [ "bg-image" ], separator: "," },
3508+
"background-origin": { multi: [ "box" ], separator: "," },
35053509
"background-position": 1,
35063510
"background-repeat": [ "repeat | repeat-x | repeat-y | no-repeat | inherit" ],
35073511
"background-size": 1,
@@ -3659,7 +3663,7 @@ var Properties = {
36593663
"line-stacking-strategy": 1,
36603664
"list-style": 1,
36613665
"list-style-image": [ "uri", "none | inherit" ],
3662-
"list-style-position": [ "inside | outsider | inherit" ],
3666+
"list-style-position": [ "inside | outside | inherit" ],
36633667
"list-style-type": [ "disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit" ],
36643668

36653669
//M
@@ -3769,6 +3773,7 @@ var Properties = {
37693773
"text-indent": [ "length", "percentage", "inherit" ],
37703774
"text-justify": [ "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida" ],
37713775
"text-outline": 1,
3776+
"text-overflow": 1,
37723777
"text-shadow": 1,
37733778
"text-transform": [ "capitalize | uppercase | lowercase | none | inherit" ],
37743779
"text-wrap": [ "normal | none | avoid" ],
@@ -3852,8 +3857,10 @@ var Properties = {
38523857
i, len, j, count,
38533858
msg,
38543859
values,
3860+
last,
38553861
parts = value.parts;
38563862

3863+
//if there's a maximum set, use it (max can't be 0)
38573864
if (spec.max) {
38583865
if (parts.length > spec.max){
38593866
throw new ValidationError("Expected a max of " + spec.max + " property values but found " + parts.length + ".", value.line, value.col);
@@ -3867,25 +3874,45 @@ var Properties = {
38673874
for (i=0, len=parts.length; i < len; i++){
38683875
msg = [];
38693876
valid = false;
3870-
for (j=0, count=values.length; j < count; j++){
3871-
if (typeof ValidationType[values[j]] == "undefined"){
3872-
if(ValidationType.identifier(parts[i], values[j])){
3873-
valid = true;
3874-
break;
3875-
}
3876-
msg.push("one of (" + values[j] + ")");
3877+
3878+
if (spec.separator && parts[i].type == "operator"){
3879+
3880+
//two operators in a row - not allowed?
3881+
if ((last && last.type == "operator")){
3882+
msg = msg.concat(values);
3883+
} else if (i == len-1){
3884+
msg = msg.concat("end of line");
3885+
} else if (parts[i] != spec.separator){
3886+
msg.push("'" + spec.separator + "'");
38773887
} else {
3878-
if (ValidationType[values[j]](parts[i])){
3879-
valid = true;
3880-
break;
3881-
}
3882-
msg.push(values[j]);
3883-
}
3888+
valid = true;
3889+
}
3890+
} else {
3891+
3892+
for (j=0, count=values.length; j < count; j++){
3893+
if (typeof ValidationType[values[j]] == "undefined"){
3894+
if(ValidationType.identifier(parts[i], values[j])){
3895+
valid = true;
3896+
break;
3897+
}
3898+
msg.push("one of (" + values[j] + ")");
3899+
} else {
3900+
if (ValidationType[values[j]](parts[i])){
3901+
valid = true;
3902+
break;
3903+
}
3904+
msg.push(values[j]);
3905+
}
3906+
}
38843907
}
3908+
38853909

38863910
if (!valid) {
38873911
throw new ValidationError("Expected " + msg.join(" or ") + " but found '" + parts[i] + "'.", value.line, value.col);
38883912
}
3913+
3914+
3915+
last = parts[i];
38893916
}
38903917

38913918
};
@@ -3923,7 +3950,6 @@ PropertyName.prototype.constructor = PropertyName;
39233950
PropertyName.prototype.toString = function(){
39243951
return (this.hack ? this.hack : "") + this.text;
39253952
};
3926-
39273953
/**
39283954
* Represents a single part of a CSS property value, meaning that it represents
39293955
* just everything single part between ":" and ";". If there are multiple values
@@ -3952,7 +3978,6 @@ function PropertyValue(parts, line, col){
39523978
PropertyValue.prototype = new SyntaxUnit();
39533979
PropertyValue.prototype.constructor = PropertyValue;
39543980

3955-
39563981
/**
39573982
* Represents a single part of a CSS property value, meaning that it represents
39583983
* just one part of the data between ":" and ";".
@@ -4060,6 +4085,29 @@ function PropertyValuePart(text, line, col){
40604085
this.red = +RegExp.$1 * 255 / 100;
40614086
this.green = +RegExp.$2 * 255 / 100;
40624087
this.blue = +RegExp.$3 * 255 / 100;
4088+
} else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //rgba() color with absolute numbers
4089+
this.type = "color";
4090+
this.red = +RegExp.$1;
4091+
this.green = +RegExp.$2;
4092+
this.blue = +RegExp.$3;
4093+
this.alpha = +RegExp.$4;
4094+
} else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //rgba() color with percentages
4095+
this.type = "color";
4096+
this.red = +RegExp.$1 * 255 / 100;
4097+
this.green = +RegExp.$2 * 255 / 100;
4098+
this.blue = +RegExp.$3 * 255 / 100;
4099+
this.alpha = +RegExp.$4;
4100+
} else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){ //hsl()
4101+
this.type = "color";
4102+
this.hue = +RegExp.$1;
4103+
this.saturation = +RegExp.$2 / 100;
4104+
this.lightness = +RegExp.$3 / 100;
4105+
} else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //hsla() color with percentages
4106+
this.type = "color";
4107+
this.hue = +RegExp.$1;
4108+
this.saturation = +RegExp.$2 / 100;
4109+
this.lightness = +RegExp.$3 / 100;
4110+
this.alpha = +RegExp.$4;
40634111
} else if (/^url\(["']?([^\)"']+)["']?\)/i.test(text)){ //URI
40644112
this.type = "uri";
40654113
this.uri = RegExp.$1;
@@ -4144,7 +4192,6 @@ function Selector(parts, line, col){
41444192
Selector.prototype = new SyntaxUnit();
41454193
Selector.prototype.constructor = Selector;
41464194

4147-
41484195
/**
41494196
* Represents a single part of a selector string, meaning a single set of
41504197
* element name and modifiers. This does not include combinators such as
@@ -4186,7 +4233,6 @@ function SelectorPart(elementName, modifiers, text, line, col){
41864233
SelectorPart.prototype = new SyntaxUnit();
41874234
SelectorPart.prototype.constructor = SelectorPart;
41884235

4189-
41904236
/**
41914237
* Represents a selector modifier string, meaning a class name, element name,
41924238
* element ID, pseudo rule, etc.
@@ -4222,7 +4268,6 @@ function SelectorSubPart(text, type, line, col){
42224268
SelectorSubPart.prototype = new SyntaxUnit();
42234269
SelectorSubPart.prototype.constructor = SelectorSubPart;
42244270

4225-
42264271
/**
42274272
* Represents a selector's specificity.
42284273
* @namespace parserlib.css
@@ -4345,7 +4390,6 @@ Specificity.calculate = function(selector){
43454390
};
43464391

43474392

4348-
43494393
var h = /^[0-9a-fA-F]$/,
43504394
nonascii = /^[\u0080-\uFFFF]$/,
43514395
nl = /\n|\r\n|\r|\f/;
@@ -5343,7 +5387,6 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
53435387
}
53445388
});
53455389

5346-
53475390
var Tokens = [
53485391

53495392
/*
@@ -5550,7 +5593,6 @@ var Tokens = [
55505593

55515594

55525595

5553-
55545596
/**
55555597
* Type to use when a validation error occurs.
55565598
* @class ValidationError
@@ -5588,7 +5630,6 @@ function ValidationError(message, line, col){
55885630
//inherit from Error
55895631
ValidationError.prototype = new Error();
55905632

5591-
55925633
parserlib.css = {
55935634
Colors :Colors,
55945635
Combinator :Combinator,
@@ -5607,9 +5648,6 @@ Tokens :Tokens,
56075648
ValidationError :ValidationError
56085649
};
56095650
})();
5610-
5611-
5612-
56135651
/**
56145652
* Main CSSLint object.
56155653
* @class CSSLint
@@ -5623,7 +5661,7 @@ var CSSLint = (function(){
56235661
formatters = [],
56245662
api = new parserlib.util.EventTarget();
56255663

5626-
api.version = "0.8.1";
5664+
api.version = "0.8.5";
56275665

56285666
//-------------------------------------------------------------------------
56295667
// Rule Management
@@ -5791,7 +5829,6 @@ var CSSLint = (function(){
57915829
return api;
57925830

57935831
})();
5794-
57955832
/*global CSSLint*/
57965833
/**
57975834
* An instance of Report is used to report results of the
@@ -8148,6 +8185,4 @@ CSSLint.addFormatter({
81488185
}
81498186
});
81508187

8151-
81528188
exports.CSSLint = CSSLint;
8153-

0 commit comments

Comments
 (0)