diff --git a/.travis.yml b/.travis.yml index 88599cd7..422c58e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,16 @@ +sudo: false + language: node_js + node_js: - "0.6" - "0.8" - "0.10" - - "0.11" - - "0.12" + - "4" + - "5" + script: - ant test + +matrix: + fast_finish: true diff --git a/README.md b/README.md index 4ed21751..3780b62e 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,12 @@ -CSS Parser -========== +# CSS Parser [![build status](https://secure.travis-ci.org/CSSLint/parser-lib.svg)](http://travis-ci.org/CSSLint/parser-lib) -Introduction ------------- +## Introduction The ParserLib CSS parser is a CSS3 SAX-inspired parser written in JavaScript. By default, the parser only deals with standard CSS syntax and doesn't do validation (checking of property names and values). -Adding to your project ----------------------- +## Adding to your project The CSS parser is intended for use primarily in command line JavaScript environments. The files you should use are in the `build` directory. Copy the files to an appropriate location for your usage. @@ -40,8 +37,7 @@ Or include it as its component parts, the ParserLib core and the CSS parser: ``` Note that parsing large JavaScript files may cause the browser to become unresponsive. -Basic usage ------------ +## Basic usage You can create a new instance of the parser by using the following code: ```js @@ -66,8 +62,7 @@ The `parse()` method throws an error if a non-recoverable syntax error occurs, o Note: The `parseStyleSheet()` method is provided for compatibility with SAC-based APIs but does the exact same thing as `parse()`. -Understanding syntax units --------------------------- +## Understanding syntax units The CSS parser defines several types that inherit from `parserlib.util.SyntaxUnit`. These types are designed to give you easy access to all relevant parts of the CSS syntax. @@ -131,16 +126,15 @@ Each instance of `parserlib.css.SelectorPart` has an `elementName` property, whi Each instance of `parserlib.css.Combinator` has an additional `type` property that indicates the type of combinator: "descendant", "child", "sibling", or "adjacent-sibling". -Using events ------------- +## Using events The CSS parser fires events as it parses text. The events correspond to important parts of the parsing algorithm and are designed to provide developers with all of the information necessary to create lint checkers, ASTs, and other data structures. For many events, the `event` object contains additional information. This additional information is most frequently in the form of a `parserlib.util.SyntaxUnit` object, which has three properties: 1. `text` - the string value -1. `line` - the line on which this token appeared -1. `col` - the column within the line at which this token appeared +2. `line` - the line on which this token appeared +3. `col` - the column within the line at which this token appeared The `toString()` method for these objects is overridden to be the same value as `text`, so that you can treat the object as a string for comparison and concatenation purposes. @@ -293,8 +287,8 @@ parser.addListener("error", function(event){ console.log("Parse error: " + event.message + " (" + event.line + "," + event.col + ")", "error"); }); ``` -Error recovery --------------- + +## Error recovery The CSS parser's goal is to be on-par with error recovery of CSS parsers in browsers. To that end, the following error recovery mechanisms are in place: @@ -318,7 +312,6 @@ a:hover, foo ... bar { * **Unknown @ Rules** - any @ rules that isn't recognized is automatically skipped, meaning the entire block after it is not parsed. -Running Tests -------------- +## Running Tests With the Apache Ant build tool installed, you can run the tests via `ant test` from the repository's root. diff --git a/src/css/Colors.js b/src/css/Colors.js index 1dd82000..3b727563 100644 --- a/src/css/Colors.js +++ b/src/css/Colors.js @@ -147,6 +147,8 @@ var Colors = { whitesmoke :"#f5f5f5", yellow :"#ffff00", yellowgreen :"#9acd32", + //'currentColor' color keyword http://www.w3.org/TR/css3-color/#currentcolor + currentColor :"The value of the 'color' property.", //CSS2 system colors http://www.w3.org/TR/css3-color/#css2-system activeBorder :"Active window border.", activecaption :"Active window caption.", diff --git a/src/css/Properties.js b/src/css/Properties.js index e69a0360..0bceae8d 100644 --- a/src/css/Properties.js +++ b/src/css/Properties.js @@ -506,8 +506,8 @@ var Properties = { "text-transform" : "capitalize | uppercase | lowercase | none | inherit", "text-wrap" : "normal | none | avoid", "top" : " | inherit", - "-ms-touch-action" : "auto | none | pan-x | pan-y", - "touch-action" : "auto | none | pan-x | pan-y", + "-ms-touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation", + "touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation", "transform" : 1, "transform-origin" : 1, "transform-style" : 1, @@ -523,7 +523,7 @@ var Properties = { "user-select" : "none | text | toggle | element | elements | all | inherit", //V - "vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | | ", + "vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | | | inherit", "visibility" : "visible | hidden | collapse | inherit", "voice-balance" : 1, "voice-duration" : 1, diff --git a/src/css/PropertyValuePart.js b/src/css/PropertyValuePart.js index 70545233..05872edc 100644 --- a/src/css/PropertyValuePart.js +++ b/src/css/PropertyValuePart.js @@ -50,6 +50,10 @@ function PropertyValuePart(text, line, col){ case "vmin": this.type = "length"; break; + + case "fr": + this.type = "grid"; + break; case "deg": case "rad": diff --git a/tests/css/Validation.js b/tests/css/Validation.js index 593f8872..53691856 100644 --- a/tests/css/Validation.js +++ b/tests/css/Validation.js @@ -931,11 +931,16 @@ "auto", "none", "pan-x", - "pan-y" + "pan-y", + "pan-left", + "pan-right", + "pan-up", + "pan-down" + "manipulation" ], invalid: { - "foo" : "Expected (auto | none | pan-x | pan-y) but found 'foo'." + "foo" : "Expected (auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation) but found 'foo'." } })); @@ -946,11 +951,38 @@ "auto", "none", "pan-x", - "pan-y" + "pan-y", + "pan-left", + "pan-right", + "pan-up", + "pan-down" + "manipulation" ], invalid: { - "foo" : "Expected (auto | none | pan-x | pan-y) but found 'foo'." + "foo" : "Expected (auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation) but found 'foo'." + } + })); + + suite.add(new ValidationTestCase({ + property: "vertical-align", + + valid: [ + "baseline", + "sub", + "super", + "top", + "text-top", + "middle", + "bottom", + "text-bottom", + "25%", + "-1px", + "inherit" + ], + + invalid: { + "foo" : "Expected (auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | | | inherit) but found 'foo'." } }));