@projectwallace/css-parser 0.4.0 → 0.5.0
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.
package/dist/parse-selector.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as CSSDataArena,
|
|
2
|
-
import { S as SelectorParser } from './selector-parser-
|
|
1
|
+
import { K as CSSDataArena, m as NODE_SELECTOR_LIST, C as CSSNode } from './string-utils-tMt2O9RW.js';
|
|
2
|
+
import { S as SelectorParser } from './selector-parser-C-u1epDB.js';
|
|
3
3
|
|
|
4
4
|
function parse_selector(source) {
|
|
5
5
|
const arena = new CSSDataArena(CSSDataArena.capacity_for_source(source.length));
|
|
@@ -7,7 +7,7 @@ function parse_selector(source) {
|
|
|
7
7
|
const selector_index = selector_parser.parse_selector(0, source.length);
|
|
8
8
|
if (selector_index === null) {
|
|
9
9
|
const empty = arena.create_node();
|
|
10
|
-
arena.set_type(empty,
|
|
10
|
+
arena.set_type(empty, NODE_SELECTOR_LIST);
|
|
11
11
|
arena.set_start_offset(empty, 0);
|
|
12
12
|
arena.set_length(empty, 0);
|
|
13
13
|
arena.set_start_line(empty, 1);
|
package/dist/parse.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { L as Lexer, y as TOKEN_EOF, q as TOKEN_COMMA, h as TOKEN_DELIM, a as TOKEN_FUNCTION, c as TOKEN_HASH, d as TOKEN_STRING, k as TOKEN_DIMENSION, j as TOKEN_PERCENTAGE, i as TOKEN_NUMBER, T as TOKEN_IDENT, t as TOKEN_LEFT_PAREN, u as TOKEN_RIGHT_PAREN, b as TOKEN_AT_KEYWORD, v as TOKEN_LEFT_BRACE, w as TOKEN_RIGHT_BRACE, o as TOKEN_COLON, p as TOKEN_SEMICOLON } from './lexer-DXablYMZ.js';
|
|
2
|
-
import { J as is_whitespace, f as NODE_VALUE_KEYWORD, g as NODE_VALUE_NUMBER, h as NODE_VALUE_DIMENSION, i as NODE_VALUE_STRING, j as NODE_VALUE_COLOR, l as NODE_VALUE_OPERATOR, k as NODE_VALUE_FUNCTION, K as CSSDataArena, e as NODE_STYLESHEET, C as CSSNode, N as NODE_STYLE_RULE, L as FLAG_HAS_BLOCK, M as FLAG_HAS_DECLARATIONS,
|
|
3
|
-
import { S as SelectorParser } from './selector-parser-
|
|
2
|
+
import { J as is_whitespace, f as NODE_VALUE_KEYWORD, g as NODE_VALUE_NUMBER, h as NODE_VALUE_DIMENSION, i as NODE_VALUE_STRING, j as NODE_VALUE_COLOR, l as NODE_VALUE_OPERATOR, k as NODE_VALUE_FUNCTION, K as CSSDataArena, e as NODE_STYLESHEET, C as CSSNode, N as NODE_STYLE_RULE, L as FLAG_HAS_BLOCK, M as FLAG_HAS_DECLARATIONS, m as NODE_SELECTOR_LIST, c as NODE_DECLARATION, O as is_vendor_prefixed, P as FLAG_VENDOR_PREFIXED, Q as trim_boundaries, I as FLAG_IMPORTANT, a as NODE_AT_RULE } from './string-utils-tMt2O9RW.js';
|
|
3
|
+
import { S as SelectorParser } from './selector-parser-C-u1epDB.js';
|
|
4
4
|
import { A as AtRulePreludeParser } from './at-rule-prelude-parser-Cj8ecgQp.js';
|
|
5
5
|
|
|
6
6
|
const CH_PLUS = 43;
|
|
@@ -325,7 +325,7 @@ class Parser {
|
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
let selector = this.arena.create_node();
|
|
328
|
-
this.arena.set_type(selector,
|
|
328
|
+
this.arena.set_type(selector, NODE_SELECTOR_LIST);
|
|
329
329
|
this.arena.set_start_line(selector, selector_line);
|
|
330
330
|
this.arena.set_start_column(selector, selector_column);
|
|
331
331
|
this.arena.set_start_offset(selector, selector_start);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { L as Lexer, q as TOKEN_COMMA, y as TOKEN_EOF, l as TOKEN_WHITESPACE, a as TOKEN_FUNCTION, o as TOKEN_COLON, r as TOKEN_LEFT_BRACKET, h as TOKEN_DELIM, c as TOKEN_HASH, T as TOKEN_IDENT, s as TOKEN_RIGHT_BRACKET, t as TOKEN_LEFT_PAREN, u as TOKEN_RIGHT_PAREN } from './lexer-DXablYMZ.js';
|
|
2
|
-
import {
|
|
2
|
+
import { m as NODE_SELECTOR_LIST, J as is_whitespace, o as NODE_SELECTOR_CLASS, q as NODE_SELECTOR_ATTRIBUTE, Q as trim_boundaries, s as NODE_SELECTOR_PSEUDO_ELEMENT, r as NODE_SELECTOR_PSEUDO_CLASS, O as is_vendor_prefixed, P as FLAG_VENDOR_PREFIXED, n as NODE_SELECTOR_TYPE, p as NODE_SELECTOR_ID, u as NODE_SELECTOR_UNIVERSAL, v as NODE_SELECTOR_NESTING, t as NODE_SELECTOR_COMBINATOR } from './string-utils-tMt2O9RW.js';
|
|
3
3
|
|
|
4
4
|
class SelectorParser {
|
|
5
5
|
lexer;
|
|
@@ -13,30 +13,20 @@ class SelectorParser {
|
|
|
13
13
|
this.selector_end = 0;
|
|
14
14
|
}
|
|
15
15
|
// Parse a selector range into selector nodes
|
|
16
|
-
// Always returns a
|
|
16
|
+
// Always returns a NODE_SELECTOR_LIST with selector components as children
|
|
17
17
|
parse_selector(start, end, line = 1, column = 1) {
|
|
18
18
|
this.selector_end = end;
|
|
19
19
|
this.lexer.pos = start;
|
|
20
20
|
this.lexer.line = line;
|
|
21
21
|
this.lexer.column = column;
|
|
22
|
-
|
|
23
|
-
if (innerSelector === null) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
let selectorWrapper = this.arena.create_node();
|
|
27
|
-
this.arena.set_type(selectorWrapper, NODE_SELECTOR);
|
|
28
|
-
this.arena.set_start_offset(selectorWrapper, start);
|
|
29
|
-
this.arena.set_length(selectorWrapper, end - start);
|
|
30
|
-
this.arena.set_start_line(selectorWrapper, line);
|
|
31
|
-
this.arena.set_start_column(selectorWrapper, column);
|
|
32
|
-
this.arena.set_first_child(selectorWrapper, innerSelector);
|
|
33
|
-
this.arena.set_last_child(selectorWrapper, innerSelector);
|
|
34
|
-
return selectorWrapper;
|
|
22
|
+
return this.parse_selector_list();
|
|
35
23
|
}
|
|
36
24
|
// Parse comma-separated selectors
|
|
37
25
|
parse_selector_list() {
|
|
38
26
|
let selectors = [];
|
|
39
27
|
let list_start = this.lexer.pos;
|
|
28
|
+
let list_line = this.lexer.line;
|
|
29
|
+
let list_column = this.lexer.column;
|
|
40
30
|
while (this.lexer.pos < this.selector_end) {
|
|
41
31
|
let selector = this.parse_complex_selector();
|
|
42
32
|
if (selector !== null) {
|
|
@@ -53,16 +43,13 @@ class SelectorParser {
|
|
|
53
43
|
break;
|
|
54
44
|
}
|
|
55
45
|
}
|
|
56
|
-
if (selectors.length
|
|
57
|
-
return selectors[0];
|
|
58
|
-
}
|
|
59
|
-
if (selectors.length > 1) {
|
|
46
|
+
if (selectors.length >= 1) {
|
|
60
47
|
let list_node = this.arena.create_node();
|
|
61
48
|
this.arena.set_type(list_node, NODE_SELECTOR_LIST);
|
|
62
49
|
this.arena.set_start_offset(list_node, list_start);
|
|
63
50
|
this.arena.set_length(list_node, this.lexer.pos - list_start);
|
|
64
|
-
this.arena.set_start_line(list_node,
|
|
65
|
-
this.arena.set_start_column(list_node,
|
|
51
|
+
this.arena.set_start_line(list_node, list_line);
|
|
52
|
+
this.arena.set_start_column(list_node, list_column);
|
|
66
53
|
this.arena.set_first_child(list_node, selectors[0]);
|
|
67
54
|
this.arena.set_last_child(list_node, selectors[selectors.length - 1]);
|
|
68
55
|
for (let i = 0; i < selectors.length - 1; i++) {
|
package/package.json
CHANGED