//if it gets here, there wasn't a valid token, so time to explode
this._unexpectedToken(tokenStream.LT(1));
//-----------------------------------------------------------------
//-----------------------------------------------------------------
* Not part of CSS grammar, but useful for skipping over
* combination of white space and HTML-style comments.
while (this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])) {
* Not part of CSS grammar, but this pattern occurs frequently
* in the official CSS grammar. Split out here to eliminate
* @param {Boolean} checkStart Indicates if the rule should check
* for the left brace at the beginning.
* @param {Boolean} readMargins Indicates if the rule should check
* @method _readDeclarations
_readDeclarations: function(checkStart, readMargins) {
* S* '{' S* declaration [ ';' S* declaration ]* '}' S*
* S* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S*
* Note that this is how it is described in CSS3 Paged Media, but is actually incorrect.
* A semicolon is only necessary following a declaration if there's another declaration
var tokenStream = this._tokenStream,
tokenStream.mustMatch(Tokens.LBRACE);
if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())) {
} else if (this._declaration()) {
if (!tokenStream.match(Tokens.SEMICOLON)) {
//if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){
tokenStream.mustMatch(Tokens.RBRACE);
if (ex instanceof SyntaxError && !this.options.strict) {
//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
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
//not a syntax error, rethrow it
* In some cases, you can end up with two white space tokens in a
* row. Instead of making a change in every function that looks for
* white space, this function is used to match as much white space
* @method _readWhitespace
* @return {String} The white space if found, empty string if not.
_readWhitespace: function() {
var tokenStream = this._tokenStream,
while (tokenStream.match(Tokens.S)) {
ws += tokenStream.token().value;
* Throws an error when an unexpected token is found.
* @param {Object} token The token that was found.
* @method _unexpectedToken
_unexpectedToken: function(token) {
throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
* Helper method used for parsing subparts of a style sheet.
if (this._tokenStream.LA(1) !== Tokens.EOF) {
this._unexpectedToken(this._tokenStream.LT(1));
//-----------------------------------------------------------------
//-----------------------------------------------------------------
_validateProperty: function(property, value) {
Validation.validate(property, value);
//-----------------------------------------------------------------
//-----------------------------------------------------------------
this._tokenStream = new TokenStream(input, Tokens);
parseStyleSheet: function(input) {
return this.parse(input);
parseMediaQuery: function(input) {
this._tokenStream = new TokenStream(input, Tokens);
var result = this._media_query();
//if there's anything more, then it's an invalid selector
//otherwise return result
* Parses a property value (everything after the semicolon).
* @return {parserlib.css.PropertyValue} The property value.
* @throws parserlib.util.SyntaxError If an unexpected token is found.
* @method parserPropertyValue
parsePropertyValue: function(input) {
this._tokenStream = new TokenStream(input, Tokens);
var result = this._expr();
//okay to have a trailing white space
//if there's anything more, then it's an invalid selector
//otherwise return result
* Parses a complete CSS rule, including selectors and
* @param {String} input The text to parser.
* @return {Boolean} True if the parse completed successfully, false if not.
parseRule: function(input) {
this._tokenStream = new TokenStream(input, Tokens);
//skip any leading white space
var result = this._ruleset();
//skip any trailing white space
//if there's anything more, then it's an invalid selector
//otherwise return result
* Parses a single CSS selector (no comma)
* @param {String} input The text to parse as a CSS selector.
* @return {Selector} An object representing the selector.
* @throws parserlib.util.SyntaxError If an unexpected token is found.
parseSelector: function(input) {
this._tokenStream = new TokenStream(input, Tokens);
//skip any leading white space
var result = this._selector();
//skip any trailing white space
//if there's anything more, then it's an invalid selector
//otherwise return result
* Parses an HTML style attribute: a set of CSS declarations
* separated by semicolons.
* @param {String} input The text to parse as a style attribute
* @method parseStyleAttribute
parseStyleAttribute: function(input) {
input += "}"; // for error recovery in _readDeclarations()
this._tokenStream = new TokenStream(input, Tokens);
this._readDeclarations();
//copy over onto prototype
for (prop in additions) {
if (Object.prototype.hasOwnProperty.call(additions, prop)) {
proto[prop] = additions[prop];
: S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
},{"../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){
/* exported Properties */
var Properties = module.exports = {
"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 | <percentage> | <length>",
"alignment-baseline" : "auto | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
"animation-delay" : "<time>#",
"animation-direction" : "<single-animation-direction>#",
"animation-duration" : "<time>#",
"animation-fill-mode" : "[ none | forwards | backwards | both ]#",
"animation-iteration-count" : "[ <number> | infinite ]#",
"animation-name" : "[ none | <single-animation-name> ]#",
"animation-play-state" : "[ running | paused ]#",
"animation-timing-function" : 1,
"-moz-animation-delay" : "<time>#",
"-moz-animation-direction" : "[ normal | alternate ]#",
"-moz-animation-duration" : "<time>#",
"-moz-animation-iteration-count" : "[ <number> | infinite ]#",
"-moz-animation-name" : "[ none | <single-animation-name> ]#",
"-moz-animation-play-state" : "[ running | paused ]#",
"-ms-animation-delay" : "<time>#",
"-ms-animation-direction" : "[ normal | alternate ]#",
"-ms-animation-duration" : "<time>#",
"-ms-animation-iteration-count" : "[ <number> | infinite ]#",
"-ms-animation-name" : "[ none | <single-animation-name> ]#",
"-ms-animation-play-state" : "[ running | paused ]#",
"-webkit-animation-delay" : "<time>#",
"-webkit-animation-direction" : "[ normal | alternate ]#",
"-webkit-animation-duration" : "<time>#",
"-webkit-animation-fill-mode" : "[ none | forwards | backwards | both ]#",
"-webkit-animation-iteration-count" : "[ <number> | infinite ]#",
"-webkit-animation-name" : "[ none | <single-animation-name> ]#",
"-webkit-animation-play-state" : "[ running | paused ]#",
"-o-animation-delay" : "<time>#",
"-o-animation-direction" : "[ normal | alternate ]#",
"-o-animation-duration" : "<time>#",
"-o-animation-iteration-count" : "[ <number> | infinite ]#",
"-o-animation-name" : "[ none | <single-animation-name> ]#",
"-o-animation-play-state" : "[ running | paused ]#",
"appearance" : "none | auto",
"-moz-appearance" : "none | button | button-arrow-down | button-arrow-next | button-arrow-previous | button-arrow-up | button-bevel | button-focus | caret | checkbox | checkbox-container | checkbox-label | checkmenuitem | dualbutton | groupbox | listbox | listitem | menuarrow | menubar | menucheckbox | menuimage | menuitem | menuitemtext | menulist | menulist-button | menulist-text | menulist-textfield | menupopup | menuradio | menuseparator | meterbar | meterchunk | progressbar | progressbar-vertical | progresschunk | progresschunk-vertical | radio | radio-container | radio-label | radiomenuitem | range | range-thumb | resizer | resizerpanel | scale-horizontal | scalethumbend | scalethumb-horizontal | scalethumbstart | scalethumbtick | scalethumb-vertical | scale-vertical | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical | searchfield | separator | sheet | spinner | spinner-downbutton | spinner-textfield | spinner-upbutton | splitter | statusbar | statusbarpanel | tab | tabpanel | tabpanels | tab-scroll-arrow-back | tab-scroll-arrow-forward | textfield | textfield-multiline | toolbar | toolbarbutton | toolbarbutton-dropdown | toolbargripper | toolbox | tooltip | treeheader | treeheadercell | treeheadersortarrow | treeitem | treeline | treetwisty | treetwistyopen | treeview | -moz-mac-unified-toolbar | -moz-win-borderless-glass | -moz-win-browsertabbar-toolbox | -moz-win-communicationstext | -moz-win-communications-toolbox | -moz-win-exclude-glass | -moz-win-glass | -moz-win-mediatext | -moz-win-media-toolbox | -moz-window-button-box | -moz-window-button-box-maximized | -moz-window-button-close | -moz-window-button-maximize | -moz-window-button-minimize | -moz-window-button-restore | -moz-window-frame-bottom | -moz-window-frame-left | -moz-window-frame-right | -moz-window-titlebar | -moz-window-titlebar-maximized",
"-ms-appearance" : "none | icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal",
"-webkit-appearance" : "none | button | button-bevel | caps-lock-indicator | caret | checkbox | default-button | listbox | listitem | media-fullscreen-button | media-mute-button | media-play-button | media-seek-back-button | media-seek-forward-button | media-slider | media-sliderthumb | menulist | menulist-button | menulist-text | menulist-textfield | push-button | radio | searchfield | searchfield-cancel-button | searchfield-decoration | searchfield-results-button | searchfield-results-decoration | slider-horizontal | slider-vertical | sliderthumb-horizontal | sliderthumb-vertical | square-button | textarea | textfield | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbargripper-horizontal | scrollbargripper-vertical | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical",
"-o-appearance" : "none | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal",
"backface-visibility" : "visible | hidden",
"background-attachment" : "<attachment>#",
"background-clip" : "<box>#",
"background-color" : "<color>",
"background-image" : "<bg-image>#",
"background-origin" : "<box>#",
"background-position" : "<bg-position>",
"background-repeat" : "<repeat-style>#",
"background-size" : "<bg-size>#",
"baseline-shift" : "baseline | sub | super | <percentage> | <length>",
"bookmark-label" : "<content> | <attr> | <string>",
"bookmark-level" : "none | <integer>",
"bookmark-state" : "open | closed",
"bookmark-target" : "none | <uri> | <attr>",
"border" : "<border-width> || <border-style> || <color>",
"border-bottom" : "<border-width> || <border-style> || <color>",
"border-bottom-color" : "<color>",
"border-bottom-left-radius" : "<x-one-radius>",
"border-bottom-right-radius" : "<x-one-radius>",
"border-bottom-style" : "<border-style>",
"border-bottom-width" : "<border-width>",
"border-collapse" : "collapse | separate",
"border-color" : "<color>{1,4}",
"border-image-outset" : "[ <length> | <number> ]{1,4}",
"border-image-repeat" : "[ stretch | repeat | round ]{1,2}",
"border-image-slice" : "<border-image-slice>",
"border-image-source" : "<image> | none",
"border-image-width" : "[ <length> | <percentage> | <number> | auto ]{1,4}",
"border-left" : "<border-width> || <border-style> || <color>",
"border-left-color" : "<color>",
"border-left-style" : "<border-style>",
"border-left-width" : "<border-width>",
"border-radius" : "<border-radius>",
"border-right" : "<border-width> || <border-style> || <color>",
"border-right-color" : "<color>",
"border-right-style" : "<border-style>",
"border-right-width" : "<border-width>",
"border-spacing" : "<length>{1,2}",
"border-style" : "<border-style>{1,4}",
"border-top" : "<border-width> || <border-style> || <color>",
"border-top-color" : "<color>",
"border-top-left-radius" : "<x-one-radius>",
"border-top-right-radius" : "<x-one-radius>",
"border-top-style" : "<border-style>",
"border-top-width" : "<border-width>",
"border-width" : "<border-width>{1,4}",
"bottom" : "<margin-width>",
"-moz-box-align" : "start | end | center | baseline | stretch",
"-moz-box-decoration-break" : "slice | clone",
"-moz-box-direction" : "normal | reverse",
"-moz-box-flex" : "<number>",
"-moz-box-flex-group" : "<integer>",
"-moz-box-lines" : "single | multiple",
"-moz-box-ordinal-group" : "<integer>",
"-moz-box-orient" : "horizontal | vertical | inline-axis | block-axis",
"-moz-box-pack" : "start | end | center | justify",
"-o-box-decoration-break" : "slice | clone",
"-webkit-box-align" : "start | end | center | baseline | stretch",
"-webkit-box-decoration-break" : "slice | clone",
"-webkit-box-direction" : "normal | reverse",
"-webkit-box-flex" : "<number>",
"-webkit-box-flex-group" : "<integer>",
"-webkit-box-lines" : "single | multiple",
"-webkit-box-ordinal-group" : "<integer>",
"-webkit-box-orient" : "horizontal | vertical | inline-axis | block-axis",
"-webkit-box-pack" : "start | end | center | justify",
"box-decoration-break" : "slice | clone",
"box-shadow" : "<box-shadow>",
"box-sizing" : "content-box | border-box",
"break-after" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
"break-before" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
"break-inside" : "auto | avoid | avoid-page | avoid-column",
"caption-side" : "top | bottom",
"clear" : "none | right | left | both",
"clip" : "<shape> | auto",
"-webkit-clip-path" : "<clip-source> | <clip-path> | none",
"clip-path" : "<clip-source> | <clip-path> | none",
"clip-rule" : "nonzero | evenodd",
"color-interpolation" : "auto | sRGB | linearRGB",
"color-interpolation-filters" : "auto | sRGB | linearRGB",
"color-rendering" : "auto | optimizeSpeed | optimizeQuality",
"column-count" : "<integer> | auto", //https://www.w3.org/TR/css3-multicol/
"column-fill" : "auto | balance",
"column-gap" : "<length> | normal",
"column-rule" : "<border-width> || <border-style> || <color>",
"column-rule-color" : "<color>",
"column-rule-style" : "<border-style>",
"column-rule-width" : "<border-width>",
"column-span" : "none | all",
"column-width" : "<length> | auto",
"crop" : "<shape> | auto",
"cue" : "cue-after | cue-before",
"direction" : "ltr | rtl",
"display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex",
"dominant-baseline" : "auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge",
"drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
"drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
"drop-initial-before-adjust" : "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
"drop-initial-before-align" : "caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
"drop-initial-size" : "auto | line | <length> | <percentage>",
"drop-initial-value" : "<integer>",
"elevation" : "<angle> | below | level | above | higher | lower",
"empty-cells" : "show | hide",
"fill-opacity" : "<opacity-value>",
"fill-rule" : "nonzero | evenodd",
"filter" : "<filter-function-list> | none",
"fit" : "fill | hidden | meet | slice",
"flex-basis" : "<width>",
"flex-direction" : "row | row-reverse | column | column-reverse",
"flex-flow" : "<flex-direction> || <flex-wrap>",
"flex-grow" : "<number>",
"flex-shrink" : "<number>",
"flex-wrap" : "nowrap | wrap | wrap-reverse",
"-webkit-flex" : "<flex>",
"-webkit-flex-basis" : "<width>",