From 12c48caf75c8bc2cc5e1d91e072ec0f9a05f6ef4 Mon Sep 17 00:00:00 2001 From: toptalo Date: Thu, 5 Oct 2017 13:28:15 +0300 Subject: [PATCH 1/3] Add support for position: -webkit-sticky --- .gitignore | 3 + dist/node-parserlib.js | 1961 ++++++++++++++++++++------------------- dist/parserlib-core.js | 76 +- dist/parserlib-css.js | 1887 ++++++++++++++++++------------------- dist/parserlib-tests.js | 55 +- dist/parserlib.js | 1961 ++++++++++++++++++++------------------- src/css/Properties.js | 2 +- 7 files changed, 3029 insertions(+), 2916 deletions(-) diff --git a/.gitignore b/.gitignore index 7d4b8771..def886ac 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ Desktop.ini # NPM files npm-debug.log node_modules + +# IDE files +.idea diff --git a/dist/node-parserlib.js b/dist/node-parserlib.js index 83282fc8..90fd637a 100644 --- a/dist/node-parserlib.js +++ b/dist/node-parserlib.js @@ -20,195 +20,195 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* Version v1.1.0, Build time: 6-December-2016 10:31:29 */ +/* Version v1.1.2, Build time: 5-October-2017 13:33:04 */ var parserlib = (function () { var require; require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o") { @@ -307,7 +307,7 @@ Matcher.parse = function(str) { var result = reader.readMatch(matcher); if (result === null) { throw new SyntaxError( - "Expected "+matcher, reader.getLine(), reader.getCol()); + "Expected " + matcher, reader.getLine(), reader.getCol()); } return result; }; @@ -359,7 +359,7 @@ Matcher.parse = function(str) { eat(/^\s*,\s*/); var max = eat(/^\d+/); eat(/^\s*\}/); - return m.braces(+min, +max); + return m.braces(Number(min), Number(max)); } return m; }; @@ -502,7 +502,7 @@ Matcher.many = function(required) { seen[i] = true; // Increase matchCount iff this was a required element // (or if all the elements are optional) - if (tryMatch(matchCount + ((required === false || required[i]) ? 1 : 0))) { + if (tryMatch(matchCount + (required === false || required[i] ? 1 : 0))) { expression.drop(); return true; } @@ -575,19 +575,39 @@ Matcher.oror = function() { Matcher.prototype = { constructor: Matcher, // These are expected to be overridden in every instance. - match: function() { throw new Error("unimplemented"); }, - toString: function() { throw new Error("unimplemented"); }, + match: function() { + throw new Error("unimplemented"); + }, + toString: function() { + throw new Error("unimplemented"); + }, // This returns a standalone function to do the matching. - func: function() { return this.match.bind(this); }, + func: function() { + return this.match.bind(this); + }, // Basic combinators - then: function(m) { return Matcher.seq(this, m); }, - or: function(m) { return Matcher.alt(this, m); }, - andand: function(m) { return Matcher.many(true, this, m); }, - oror: function(m) { return Matcher.many(false, this, m); }, + then: function(m) { + return Matcher.seq(this, m); + }, + or: function(m) { + return Matcher.alt(this, m); + }, + andand: function(m) { + return Matcher.many(true, this, m); + }, + oror: function(m) { + return Matcher.many(false, this, m); + }, // Component value multipliers - star: function() { return this.braces(0, Infinity, "*"); }, - plus: function() { return this.braces(1, Infinity, "+"); }, - question: function() { return this.braces(0, 1, "?"); }, + star: function() { + return this.braces(0, Infinity, "*"); + }, + plus: function() { + return this.braces(1, Infinity, "+"); + }, + question: function() { + return this.braces(0, 1, "?"); + }, hash: function() { return this.braces(1, Infinity, "#", Matcher.cast(",")); }, @@ -679,7 +699,7 @@ var Parser = require("./Parser"); */ function MediaQuery(modifier, mediaType, features, line, col) { - SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE); + SyntaxUnit.call(this, (modifier ? modifier + " " : "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE); /** * The media modifier ("not" or "only") @@ -744,7 +764,7 @@ var Validation = require("./Validation"); */ function Parser(options) { - //inherit event functionality + // inherit event functionality EventTarget.call(this); @@ -753,7 +773,7 @@ function Parser(options) { this._tokenStream = null; } -//Static constants +// Static constants Parser.DEFAULT_TYPE = 0; Parser.COMBINATOR_TYPE = 1; Parser.MEDIA_FEATURE_TYPE = 2; @@ -767,15 +787,15 @@ Parser.SELECTOR_SUB_PART_TYPE = 9; Parser.prototype = function() { - var proto = new EventTarget(), //new prototype + var proto = new EventTarget(), // new prototype prop, additions = { __proto__: null, - //restore constructor + // restore constructor constructor: Parser, - //instance constants - yuck + // instance constants - yuck DEFAULT_TYPE : 0, COMBINATOR_TYPE : 1, MEDIA_FEATURE_TYPE : 2, @@ -809,27 +829,27 @@ Parser.prototype = function() { this.fire("startstylesheet"); - //try to read character set + // try to read character set this._charset(); this._skipCruft(); - //try to read imports - may be more than one + // try to read imports - may be more than one while (tokenStream.peek() === Tokens.IMPORT_SYM) { this._import(); this._skipCruft(); } - //try to read namespaces - may be more than one + // try to read namespaces - may be more than one while (tokenStream.peek() === Tokens.NAMESPACE_SYM) { this._namespace(); this._skipCruft(); } - //get the next token + // get the next token tt = tokenStream.peek(); - //try to read the rest + // try to read the rest while (tt > Tokens.EOF) { try { @@ -863,11 +883,11 @@ Parser.prototype = function() { this._supports(); this._skipCruft(); break; - case Tokens.UNKNOWN_SYM: //unknown @ rule + case Tokens.UNKNOWN_SYM: // unknown @ rule tokenStream.get(); if (!this.options.strict) { - //fire error event + // fire error event this.fire({ type: "error", error: null, @@ -876,10 +896,10 @@ Parser.prototype = function() { col: tokenStream.LT(0).startCol }); - //skip braces - count=0; + // skip braces + count = 0; while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) === Tokens.LBRACE) { - count++; //keep track of nesting depth + count++; // keep track of nesting depth } while (count) { @@ -888,7 +908,7 @@ Parser.prototype = function() { } } else { - //not a syntax error, rethrow it + // not a syntax error, rethrow it throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol); } break; @@ -898,7 +918,7 @@ Parser.prototype = function() { default: if (!this._ruleset()) { - //error handling for known issues + // error handling for known issues switch (tt) { case Tokens.CHARSET_SYM: token = tokenStream.LT(1); @@ -913,7 +933,7 @@ Parser.prototype = function() { this._namespace(false); throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol); default: - tokenStream.get(); //get the last token + tokenStream.get(); // get the last token this._unexpectedToken(tokenStream.token()); } @@ -986,21 +1006,21 @@ Parser.prototype = function() { importToken, mediaList = []; - //read import symbol + // read import symbol tokenStream.mustMatch(Tokens.IMPORT_SYM); importToken = tokenStream.token(); this._readWhitespace(); tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); - //grab the URI value + // grab the URI value uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1"); this._readWhitespace(); mediaList = this._media_query_list(); - //must end with a semicolon + // must end with a semicolon tokenStream.mustMatch(Tokens.SEMICOLON); this._readWhitespace(); @@ -1028,13 +1048,13 @@ Parser.prototype = function() { prefix, uri; - //read import symbol + // read import symbol tokenStream.mustMatch(Tokens.NAMESPACE_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; this._readWhitespace(); - //it's a namespace prefix - no _namespace_prefix() method because it's just an IDENT + // it's a namespace prefix - no _namespace_prefix() method because it's just an IDENT if (tokenStream.match(Tokens.IDENT)) { prefix = tokenStream.token().value; this._readWhitespace(); @@ -1045,12 +1065,12 @@ Parser.prototype = function() { tokenStream.mustMatch(Tokens.URI); }*/ - //grab the URI value + // grab the URI value uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); this._readWhitespace(); - //must end with a semicolon + // must end with a semicolon tokenStream.mustMatch(Tokens.SEMICOLON); this._readWhitespace(); @@ -1206,9 +1226,9 @@ Parser.prototype = function() { var tokenStream = this._tokenStream, line, col, - mediaList;// = []; + mediaList; // = []; - //look for @media + // look for @media tokenStream.mustMatch(Tokens.MEDIA_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; @@ -1257,7 +1277,7 @@ Parser.prototype = function() { }, - //CSS3 Media Queries + // CSS3 Media Queries _media_query_list: function() { /* * media_query_list @@ -1303,7 +1323,7 @@ Parser.prototype = function() { if (tokenStream.match(Tokens.IDENT)) { ident = tokenStream.token().value.toLowerCase(); - //since there's no custom tokens for these, need to manually check + // since there's no custom tokens for these, need to manually check if (ident !== "only" && ident !== "not") { tokenStream.unget(); ident = null; @@ -1343,7 +1363,7 @@ Parser.prototype = function() { return new MediaQuery(ident, type, expressions, token.startLine, token.startCol); }, - //CSS3 Media Queries + // CSS3 Media Queries _media_type: function() { /* * media_type @@ -1389,7 +1409,7 @@ Parser.prototype = function() { return new MediaFeature(feature, expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null); }, - //CSS3 Media Queries + // CSS3 Media Queries _media_feature: function() { /* * media_feature @@ -1405,7 +1425,7 @@ Parser.prototype = function() { return SyntaxUnit.fromToken(tokenStream.token()); }, - //CSS3 Paged Media + // CSS3 Paged Media _page: function() { /* * page: @@ -1419,7 +1439,7 @@ Parser.prototype = function() { identifier = null, pseudoPage = null; - //look for @page + // look for @page tokenStream.mustMatch(Tokens.PAGE_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; @@ -1429,13 +1449,13 @@ Parser.prototype = function() { if (tokenStream.match(Tokens.IDENT)) { identifier = tokenStream.token().value; - //The value 'auto' may not be used as a page name and MUST be treated as a syntax error. + // The value 'auto' may not be used as a page name and MUST be treated as a syntax error. if (identifier.toLowerCase() === "auto") { this._unexpectedToken(tokenStream.token()); } } - //see if there's a colon upcoming + // see if there's a colon upcoming if (tokenStream.peek() === Tokens.COLON) { pseudoPage = this._pseudo_page(); } @@ -1462,7 +1482,7 @@ Parser.prototype = function() { }, - //CSS3 Paged Media + // CSS3 Paged Media _margin: function() { /* * margin : @@ -1499,7 +1519,7 @@ Parser.prototype = function() { } }, - //CSS3 Paged Media + // CSS3 Paged Media _margin_sym: function() { /* @@ -1526,12 +1546,12 @@ Parser.prototype = function() { var tokenStream = this._tokenStream; if (tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM, - Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM, - Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM, - Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM, - Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM, - Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM, - Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) { + Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM, + Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM, + Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM, + Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM, + Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM, + Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) { return SyntaxUnit.fromToken(tokenStream.token()); } else { return null; @@ -1551,7 +1571,7 @@ Parser.prototype = function() { tokenStream.mustMatch(Tokens.COLON); tokenStream.mustMatch(Tokens.IDENT); - //TODO: CSS3 Paged Media says only "left", "center", and "right" are allowed + // TODO: CSS3 Paged Media says only "left", "center", and "right" are allowed return tokenStream.token().value; }, @@ -1567,7 +1587,7 @@ Parser.prototype = function() { line, col; - //look for @page + // look for @page tokenStream.mustMatch(Tokens.FONT_FACE_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; @@ -1638,7 +1658,7 @@ Parser.prototype = function() { tokenStream.mustMatch(Tokens.DOCUMENT_SYM); token = tokenStream.token(); - if (/^@\-([^\-]+)\-/.test(token.value)) { + if (/^@-([^-]+)-/.test(token.value)) { prefix = RegExp.$1; } @@ -1734,7 +1754,7 @@ Parser.prototype = function() { token = null; if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) || - (inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))) { + inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS])) { token = tokenStream.token(); this._readWhitespace(); } @@ -1796,7 +1816,7 @@ Parser.prototype = function() { line, col; - //check for star hack - throws error if not allowed + // check for star hack - throws error if not allowed if (tokenStream.peek() === Tokens.STAR && this.options.starHack) { tokenStream.get(); token = tokenStream.token(); @@ -1809,20 +1829,20 @@ Parser.prototype = function() { token = tokenStream.token(); tokenValue = token.value; - //check for underscore hack - no error if not allowed because it's valid CSS syntax + // check for underscore hack - no error if not allowed because it's valid CSS syntax if (tokenValue.charAt(0) === "_" && this.options.underscoreHack) { hack = "_"; tokenValue = tokenValue.substring(1); } - value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol)); + value = new PropertyName(tokenValue, hack, line || token.startLine, col || token.startCol); this._readWhitespace(); } return value; }, - //Augmented with CSS3 Selectors + // Augmented with CSS3 Selectors _ruleset: function() { /* * ruleset @@ -1845,7 +1865,7 @@ Parser.prototype = function() { } catch (ex) { if (ex instanceof SyntaxError && !this.options.strict) { - //fire error event + // fire error event this.fire({ type: "error", error: ex, @@ -1854,25 +1874,25 @@ Parser.prototype = function() { col: ex.col }); - //skip over everything until closing brace + // skip over everything until closing brace tt = tokenStream.advance([Tokens.RBRACE]); if (tt === Tokens.RBRACE) { - //if there's a right brace, the rule is finished so don't do anything + // if there's a right brace, the rule is finished so don't do anything } else { - //otherwise, rethrow the error because it wasn't handled properly + // otherwise, rethrow the error because it wasn't handled properly throw ex; } } else { - //not a syntax error, rethrow it + // not a syntax error, rethrow it throw ex; } - //trigger parser to continue + // trigger parser to continue return true; } - //if it got here, all selectors parsed + // if it got here, all selectors parsed if (selectors) { this.fire({ @@ -1897,7 +1917,7 @@ Parser.prototype = function() { }, - //CSS3 Selectors + // CSS3 Selectors _selectors_group: function() { /* @@ -1927,7 +1947,7 @@ Parser.prototype = function() { return selectors.length ? selectors : null; }, - //CSS3 Selectors + // CSS3 Selectors _selector: function() { /* * selector @@ -1941,7 +1961,7 @@ Parser.prototype = function() { combinator = null, ws = null; - //if there's no simple selector, then there's no selector + // if there's no simple selector, then there's no selector nextSelector = this._simple_selector_sequence(); if (nextSelector === null) { return null; @@ -1951,33 +1971,33 @@ Parser.prototype = function() { do { - //look for a combinator + // look for a combinator combinator = this._combinator(); if (combinator !== null) { selector.push(combinator); nextSelector = this._simple_selector_sequence(); - //there must be a next selector + // there must be a next selector if (nextSelector === null) { this._unexpectedToken(tokenStream.LT(1)); } else { - //nextSelector is an instance of SelectorPart + // nextSelector is an instance of SelectorPart selector.push(nextSelector); } } else { - //if there's not whitespace, we're done + // if there's not whitespace, we're done if (this._readWhitespace()) { - //add whitespace separator + // add whitespace separator ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol); //combinator is not required combinator = this._combinator(); - //selector is required if there's a combinator + // selector is required if there's a combinator nextSelector = this._simple_selector_sequence(); if (nextSelector === null) { if (combinator !== null) { @@ -2003,7 +2023,7 @@ Parser.prototype = function() { return new Selector(selector, selector[0].line, selector[0].col); }, - //CSS3 Selectors + // CSS3 Selectors _simple_selector_sequence: function() { /* * simple_selector_sequence @@ -2015,16 +2035,16 @@ Parser.prototype = function() { var tokenStream = this._tokenStream, - //parts of a simple selector + // parts of a simple selector elementName = null, modifiers = [], - //complete selector text - selectorText= "", + // complete selector text + selectorText = "", - //the different parts after the element name to search for + // the different parts after the element name to search for components = [ - //HASH + // HASH function() { return tokenStream.match(Tokens.HASH) ? new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : @@ -2042,7 +2062,7 @@ Parser.prototype = function() { col; - //get starting line and column for the selector + // get starting line and column for the selector line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol; @@ -2057,19 +2077,19 @@ Parser.prototype = function() { while (true) { - //whitespace means we're done + // whitespace means we're done if (tokenStream.peek() === Tokens.S) { break; } - //check for each component + // check for each component while (i < len && component === null) { component = components[i++].call(this); } if (component === null) { - //we don't have a selector + // we don't have a selector if (selectorText === "") { return null; } else { @@ -2089,7 +2109,7 @@ Parser.prototype = function() { null; }, - //CSS3 Selectors + // CSS3 Selectors _type_selector: function() { /* * type_selector @@ -2125,7 +2145,7 @@ Parser.prototype = function() { } }, - //CSS3 Selectors + // CSS3 Selectors _class: function() { /* * class @@ -2146,7 +2166,7 @@ Parser.prototype = function() { }, - //CSS3 Selectors + // CSS3 Selectors _element_name: function() { /* * element_name @@ -2166,7 +2186,7 @@ Parser.prototype = function() { } }, - //CSS3 Selectors + // CSS3 Selectors _namespace_prefix: function() { /* * namespace_prefix @@ -2176,7 +2196,7 @@ Parser.prototype = function() { var tokenStream = this._tokenStream, value = ""; - //verify that this is a namespace prefix + // verify that this is a namespace prefix if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE) { if (tokenStream.match([Tokens.IDENT, Tokens.STAR])) { @@ -2191,7 +2211,7 @@ Parser.prototype = function() { return value.length ? value : null; }, - //CSS3 Selectors + // CSS3 Selectors _universal: function() { /* * universal @@ -2215,7 +2235,7 @@ Parser.prototype = function() { }, - //CSS3 Selectors + // CSS3 Selectors _attrib: function() { /* * attrib @@ -2251,7 +2271,7 @@ Parser.prototype = function() { value += this._readWhitespace(); if (tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH, - Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])) { + Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])) { value += tokenStream.token().value; value += this._readWhitespace(); @@ -2269,7 +2289,7 @@ Parser.prototype = function() { } }, - //CSS3 Selectors + // CSS3 Selectors _pseudo: function() { /* @@ -2312,7 +2332,7 @@ Parser.prototype = function() { return pseudo; }, - //CSS3 Selectors + // CSS3 Selectors _functional_pseudo: function() { /* * functional_pseudo @@ -2334,7 +2354,7 @@ Parser.prototype = function() { return value; }, - //CSS3 Selectors + // CSS3 Selectors _expression: function() { /* * expression @@ -2346,9 +2366,9 @@ Parser.prototype = function() { value = ""; while (tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION, - Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH, - Tokens.FREQ, Tokens.ANGLE, Tokens.TIME, - Tokens.RESOLUTION, Tokens.SLASH])) { + Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH, + Tokens.FREQ, Tokens.ANGLE, Tokens.TIME, + Tokens.RESOLUTION, Tokens.SLASH])) { value += tokenStream.token().value; value += this._readWhitespace(); @@ -2358,7 +2378,7 @@ Parser.prototype = function() { }, - //CSS3 Selectors + // CSS3 Selectors _negation: function() { /* * negation @@ -2391,7 +2411,7 @@ Parser.prototype = function() { return subpart; }, - //CSS3 Selectors + // CSS3 Selectors _negation_arg: function() { /* * negation_arg @@ -2428,12 +2448,12 @@ Parser.prototype = function() { i++; } - //must be a negation arg + // must be a negation arg if (arg === null) { this._unexpectedToken(tokenStream.LT(1)); } - //it's an element name + // it's an element name if (arg.type === "elementName") { part = new SelectorPart(arg, [], arg.toString(), line, col); } else { @@ -2452,12 +2472,12 @@ Parser.prototype = function() { * ; */ - var tokenStream = this._tokenStream, - property = null, - expr = null, - prio = null, - invalid = null, - propertyName= ""; + var tokenStream = this._tokenStream, + property = null, + expr = null, + prio = null, + invalid = null, + propertyName = ""; property = this._property(); if (property !== null) { @@ -2467,7 +2487,7 @@ Parser.prototype = function() { expr = this._expr(); - //if there's no parts for the value, it's an error + // if there's no parts for the value, it's an error if (!expr || expr.length === 0) { this._unexpectedToken(tokenStream.LT(1)); } @@ -2542,11 +2562,11 @@ Parser.prototype = function() { do { operator = this._operator(inFunction); - //if there's an operator, keep building up the value parts + // if there's an operator, keep building up the value parts if (operator) { values.push(operator); } /*else { - //if there's not an operator, you have a full value + // if there's not an operator, you have a full value values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); valueParts = []; }*/ @@ -2561,7 +2581,7 @@ Parser.prototype = function() { } while (true); } - //cleanup + // cleanup /*if (valueParts.length) { values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); }*/ @@ -2589,14 +2609,14 @@ Parser.prototype = function() { line, col; - //returns the operator or null + // returns the operator or null unary = this._unary_operator(); if (unary !== null) { line = tokenStream.token().startLine; col = tokenStream.token().startCol; } - //exception for IE filters + // exception for IE filters if (tokenStream.peek() === Tokens.IE_FUNCTION && this.options.ieFilters) { value = this._ie_function(); @@ -2605,7 +2625,7 @@ Parser.prototype = function() { col = tokenStream.token().startCol; } - //see if it's a simple block + // see if it's a simple block } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])) { token = tokenStream.token(); @@ -2619,10 +2639,10 @@ Parser.prototype = function() { value += endChar; this._readWhitespace(); - //see if there's a simple match + // see if there's a simple match } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH, - Tokens.ANGLE, Tokens.TIME, - Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])) { + Tokens.ANGLE, Tokens.TIME, + Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])) { value = tokenStream.token().value; if (unary === null) { @@ -2635,17 +2655,17 @@ Parser.prototype = function() { this._readWhitespace(); } else { - //see if it's a color + // see if it's a color token = this._hexcolor(); if (token === null) { - //if there's no unary, get the start of the next token for line/col info + // if there's no unary, get the start of the next token for line/col info if (unary === null) { line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol; } - //has to be a function + // has to be a function if (value === null) { /* @@ -2699,7 +2719,7 @@ Parser.prototype = function() { expr = this._expr(true); functionText += expr; - //START: Horrible hack in case it's an IE filter + // START: Horrible hack in case it's an IE filter if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS) { do { @@ -2707,7 +2727,7 @@ Parser.prototype = function() { functionText += tokenStream.token().value; } - //might be second time in the loop + // might be second time in the loop if (tokenStream.LA(0) === Tokens.COMMA) { functionText += tokenStream.token().value; } @@ -2728,7 +2748,7 @@ Parser.prototype = function() { } while (tokenStream.match([Tokens.COMMA, Tokens.S])); } - //END: Horrible Hack + // END: Horrible Hack tokenStream.match(Tokens.RPAREN); functionText += ")"; @@ -2750,7 +2770,7 @@ Parser.prototype = function() { functionText = null, lt; - //IE function can begin like a regular function, too + // IE function can begin like a regular function, too if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])) { functionText = tokenStream.token().value; @@ -2760,7 +2780,7 @@ Parser.prototype = function() { functionText += tokenStream.token().value; } - //might be second time in the loop + // might be second time in the loop if (tokenStream.LA(0) === Tokens.COMMA) { functionText += tokenStream.token().value; } @@ -2805,7 +2825,7 @@ Parser.prototype = function() { if (tokenStream.match(Tokens.HASH)) { - //need to do some validation here + // need to do some validation here token = tokenStream.token(); color = token.value; @@ -2837,7 +2857,7 @@ Parser.prototype = function() { tokenStream.mustMatch(Tokens.KEYFRAMES_SYM); token = tokenStream.token(); - if (/^@\-([^\-]+)\-/.test(token.value)) { + if (/^@-([^-]+)-/.test(token.value)) { prefix = RegExp.$1; } @@ -2858,7 +2878,7 @@ Parser.prototype = function() { this._readWhitespace(); tt = tokenStream.peek(); - //check for key + // check for key while (tt === Tokens.IDENT || tt === Tokens.PERCENTAGE) { this._keyframe_rule(); this._readWhitespace(); @@ -2931,7 +2951,7 @@ Parser.prototype = function() { var tokenStream = this._tokenStream, keyList = []; - //must be least one key + // must be least one key keyList.push(this._key()); this._readWhitespace(); @@ -2970,7 +2990,7 @@ Parser.prototype = function() { tokenStream.unget(); } - //if it gets here, there wasn't a valid token, so time to explode + // if it gets here, there wasn't a valid token, so time to explode this._unexpectedToken(tokenStream.LT(1)); }, @@ -2987,7 +3007,7 @@ Parser.prototype = function() { */ _skipCruft: function() { while (this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])) { - //noop + // noop } }, @@ -3030,7 +3050,7 @@ Parser.prototype = function() { while (true) { if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())) { - //noop + // noop } else if (this._declaration()) { if (!tokenStream.match(Tokens.SEMICOLON)) { break; @@ -3039,7 +3059,7 @@ Parser.prototype = function() { break; } - //if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){ + //if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)) { // break; //} this._readWhitespace(); @@ -3051,7 +3071,7 @@ Parser.prototype = function() { } catch (ex) { if (ex instanceof SyntaxError && !this.options.strict) { - //fire error event + // fire error event this.fire({ type: "error", error: ex, @@ -3060,19 +3080,19 @@ Parser.prototype = function() { col: ex.col }); - //see if there's another declaration + // see if there's another declaration tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]); if (tt === Tokens.SEMICOLON) { - //if there's a semicolon, then there might be another declaration + // if there's a semicolon, then there might be another declaration this._readDeclarations(false, readMargins); } else if (tt !== Tokens.RBRACE) { - //if there's a right brace, the rule is finished so don't do anything - //otherwise, rethrow the error because it wasn't handled properly + // if there's a right brace, the rule is finished so don't do anything + // otherwise, rethrow the error because it wasn't handled properly throw ex; } } else { - //not a syntax error, rethrow it + // not a syntax error, rethrow it throw ex; } } @@ -3141,7 +3161,7 @@ Parser.prototype = function() { }, parseStyleSheet: function(input) { - //just passthrough + // just passthrough return this.parse(input); }, @@ -3149,10 +3169,10 @@ Parser.prototype = function() { this._tokenStream = new TokenStream(input, Tokens); var result = this._media_query(); - //if there's anything more, then it's an invalid selector + // if there's anything more, then it's an invalid selector this._verifyEnd(); - //otherwise return result + // otherwise return result return result; }, @@ -3169,13 +3189,13 @@ Parser.prototype = function() { var result = this._expr(); - //okay to have a trailing white space + // okay to have a trailing white space this._readWhitespace(); - //if there's anything more, then it's an invalid selector + // if there's anything more, then it's an invalid selector this._verifyEnd(); - //otherwise return result + // otherwise return result return result; }, @@ -3189,18 +3209,18 @@ Parser.prototype = function() { parseRule: function(input) { this._tokenStream = new TokenStream(input, Tokens); - //skip any leading white space + // skip any leading white space this._readWhitespace(); var result = this._ruleset(); - //skip any trailing white space + // skip any trailing white space this._readWhitespace(); - //if there's anything more, then it's an invalid selector + // if there's anything more, then it's an invalid selector this._verifyEnd(); - //otherwise return result + // otherwise return result return result; }, @@ -3215,18 +3235,18 @@ Parser.prototype = function() { this._tokenStream = new TokenStream(input, Tokens); - //skip any leading white space + // skip any leading white space this._readWhitespace(); var result = this._selector(); - //skip any trailing white space + // skip any trailing white space this._readWhitespace(); - //if there's anything more, then it's an invalid selector + // if there's anything more, then it's an invalid selector this._verifyEnd(); - //otherwise return result + // otherwise return result return result; }, @@ -3238,13 +3258,13 @@ Parser.prototype = function() { * @method parseStyleAttribute */ parseStyleAttribute: function(input) { - input += "}"; // for error recovery in _readDeclarations() + input += "}"; // for error recovery in _readDeclarations() this._tokenStream = new TokenStream(input, Tokens); this._readDeclarations(); } }; - //copy over onto prototype + // copy over onto prototype for (prop in additions) { if (Object.prototype.hasOwnProperty.call(additions, prop)) { proto[prop] = additions[prop]; @@ -3263,40 +3283,40 @@ nth */ },{"../util/EventTarget":23,"../util/SyntaxError":25,"../util/SyntaxUnit":26,"./Combinator":2,"./MediaFeature":4,"./MediaQuery":5,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./TokenStream":17,"./Tokens":18,"./Validation":19}],7:[function(require,module,exports){ -"use strict"; - /* exported Properties */ +"use strict"; + var Properties = module.exports = { __proto__: null, - //A - "align-items" : "flex-start | flex-end | center | baseline | stretch", - "align-content" : "flex-start | flex-end | center | space-between | space-around | stretch", - "align-self" : "auto | flex-start | flex-end | center | baseline | stretch", - "all" : "initial | inherit | unset", - "-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch", - "-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch", - "-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch", - "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | | ", - "alignment-baseline" : "auto | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical", - "animation" : 1, - "animation-delay" : "