@projectwallace/css-parser 0.8.7 → 0.8.9

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.
@@ -81,8 +81,6 @@ export declare class CSSNode {
81
81
  private source;
82
82
  private index;
83
83
  constructor(arena: CSSDataArena, source: string, index: number);
84
- /** Get the arena (for internal/advanced use only) */
85
- __get_arena(): CSSDataArena;
86
84
  /** Get node type as number (for performance) */
87
85
  get type(): CSSNodeType;
88
86
  /** Get node type as human-readable string */
package/dist/css-node.js CHANGED
@@ -49,7 +49,10 @@ class CSSNode {
49
49
  this.source = source;
50
50
  this.index = index;
51
51
  }
52
- /** Get the arena (for internal/advanced use only) */
52
+ /**
53
+ * @internal
54
+ * Get the arena (for internal/advanced use only)
55
+ */
53
56
  __get_arena() {
54
57
  return this.arena;
55
58
  }
@@ -222,6 +222,8 @@ class AtRulePreludeParser {
222
222
  let token_type = this.lexer.token_type;
223
223
  if (token_type === TOKEN_IDENT) {
224
224
  let layer = this.create_node(LAYER_NAME, this.lexer.token_start, this.lexer.token_end);
225
+ this.arena.set_value_start_delta(layer, 0);
226
+ this.arena.set_value_length(layer, this.lexer.token_end - this.lexer.token_start);
225
227
  nodes.push(layer);
226
228
  } else if (token_type === TOKEN_COMMA) {
227
229
  continue;
@@ -335,6 +337,8 @@ class AtRulePreludeParser {
335
337
  if (trimmed) {
336
338
  this.arena.set_content_start_delta(layer_node, trimmed[0] - layer_start);
337
339
  this.arena.set_content_length(layer_node, trimmed[1] - trimmed[0]);
340
+ this.arena.set_value_start_delta(layer_node, trimmed[0] - layer_start);
341
+ this.arena.set_value_length(layer_node, trimmed[1] - trimmed[0]);
338
342
  }
339
343
  }
340
344
  return layer_node;
@@ -351,8 +355,10 @@ class AtRulePreludeParser {
351
355
  let text = this.source.substring(this.lexer.token_start, this.lexer.token_end - 1);
352
356
  if (str_equals("supports", text)) {
353
357
  let supports_start = this.lexer.token_start;
358
+ let content_start = this.lexer.token_end;
354
359
  let paren_depth = 1;
355
360
  let supports_end = this.lexer.token_end;
361
+ let content_end = content_start;
356
362
  while (this.lexer.pos < this.prelude_end && paren_depth > 0) {
357
363
  let tokenType = this.next_token();
358
364
  if (tokenType === TOKEN_LEFT_PAREN || tokenType === TOKEN_FUNCTION) {
@@ -360,6 +366,7 @@ class AtRulePreludeParser {
360
366
  } else if (tokenType === TOKEN_RIGHT_PAREN) {
361
367
  paren_depth--;
362
368
  if (paren_depth === 0) {
369
+ content_end = this.lexer.token_start;
363
370
  supports_end = this.lexer.token_end;
364
371
  }
365
372
  } else if (tokenType === TOKEN_EOF) {
@@ -367,6 +374,11 @@ class AtRulePreludeParser {
367
374
  }
368
375
  }
369
376
  let supports_node = this.create_node(SUPPORTS_QUERY, supports_start, supports_end);
377
+ let trimmed = trim_boundaries(this.source, content_start, content_end);
378
+ if (trimmed) {
379
+ this.arena.set_value_start_delta(supports_node, trimmed[0] - supports_start);
380
+ this.arena.set_value_length(supports_node, trimmed[1] - trimmed[0]);
381
+ }
370
382
  return supports_node;
371
383
  }
372
384
  }
@@ -43,7 +43,9 @@ class DeclarationParser {
43
43
  browser_hack_line = lexer.token_line;
44
44
  browser_hack_column = lexer.token_column;
45
45
  } else if (first_char === 45) {
46
- if (!is_vendor_prefixed(this.source, lexer.token_start, lexer.token_end)) {
46
+ const second_char = this.source.charCodeAt(lexer.token_start + 1);
47
+ const is_custom_property = second_char === 45;
48
+ if (!is_custom_property && !is_vendor_prefixed(this.source, lexer.token_start, lexer.token_end)) {
47
49
  has_browser_hack = true;
48
50
  browser_hack_start = lexer.token_start;
49
51
  browser_hack_line = lexer.token_line;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectwallace/css-parser",
3
- "version": "0.8.7",
3
+ "version": "0.8.9",
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",