@projectwallace/css-parser 0.13.1 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/parse.js +9 -2
  2. package/package.json +1 -1
package/dist/parse.js CHANGED
@@ -4,7 +4,7 @@ import { CSSNode } from './css-node.js';
4
4
  import { SelectorParser } from './parse-selector.js';
5
5
  import { AtRulePreludeParser } from './parse-atrule-prelude.js';
6
6
  import { DeclarationParser } from './parse-declaration.js';
7
- import { TOKEN_EOF, TOKEN_AT_KEYWORD, TOKEN_LEFT_BRACE, TOKEN_RIGHT_BRACE, TOKEN_IDENT, TOKEN_HASH, TOKEN_DELIM, TOKEN_LEFT_PAREN, TOKEN_RIGHT_PAREN, TOKEN_LEFT_BRACKET, TOKEN_RIGHT_BRACKET, TOKEN_COMMA, TOKEN_COLON, TOKEN_SEMICOLON } from './token-types.js';
7
+ import { TOKEN_EOF, TOKEN_AT_KEYWORD, TOKEN_LEFT_BRACE, TOKEN_RIGHT_BRACE, TOKEN_IDENT, TOKEN_HASH, TOKEN_DELIM, TOKEN_LEFT_PAREN, TOKEN_RIGHT_PAREN, TOKEN_LEFT_BRACKET, TOKEN_RIGHT_BRACKET, TOKEN_COMMA, TOKEN_COLON, TOKEN_SEMICOLON, TOKEN_FUNCTION } from './token-types.js';
8
8
  import { trim_boundaries } from './parse-utils.js';
9
9
  import { CHAR_PERIOD, CHAR_GREATER_THAN, CHAR_PLUS, CHAR_TILDE, CHAR_AMPERSAND } from './string-utils.js';
10
10
 
@@ -213,9 +213,16 @@ class Parser {
213
213
  this.arena.set_content_length(at_rule, name_length);
214
214
  let prelude_start = this.lexer.token_start;
215
215
  let prelude_end = prelude_start;
216
+ let paren_depth = 0;
216
217
  while (!this.is_eof()) {
217
218
  let token_type = this.peek_type();
218
- if (token_type === TOKEN_LEFT_BRACE || token_type === TOKEN_SEMICOLON) break;
219
+ if (token_type === TOKEN_LEFT_PAREN || token_type === TOKEN_FUNCTION) {
220
+ paren_depth++;
221
+ } else if (token_type === TOKEN_RIGHT_PAREN) {
222
+ paren_depth--;
223
+ }
224
+ if (token_type === TOKEN_LEFT_BRACE && paren_depth === 0) break;
225
+ if (token_type === TOKEN_SEMICOLON && paren_depth === 0) break;
219
226
  prelude_end = this.lexer.token_end;
220
227
  this.next_token();
221
228
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectwallace/css-parser",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "description": "High-performance CSS lexer and parser, optimized for CSS inspection and analysis",
5
5
  "author": "Bart Veneman <bart@projectwallace.com>",
6
6
  "license": "MIT",