@projectwallace/css-parser 0.8.1 → 0.8.3
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-value.js +11 -12
- package/dist/parse.js +3 -1
- package/package.json +1 -1
package/dist/parse-value.js
CHANGED
|
@@ -17,10 +17,11 @@ class ValueParser {
|
|
|
17
17
|
}
|
|
18
18
|
// Parse a declaration value range into value nodes
|
|
19
19
|
// Returns array of value node indices
|
|
20
|
-
parse_value(start, end) {
|
|
20
|
+
parse_value(start, end, start_line, start_column) {
|
|
21
21
|
this.value_end = end;
|
|
22
22
|
this.lexer.pos = start;
|
|
23
|
-
this.lexer.line =
|
|
23
|
+
this.lexer.line = start_line;
|
|
24
|
+
this.lexer.column = start_column;
|
|
24
25
|
let nodes = [];
|
|
25
26
|
while (this.lexer.pos < this.value_end) {
|
|
26
27
|
this.lexer.next_token_fast(false);
|
|
@@ -80,8 +81,8 @@ class ValueParser {
|
|
|
80
81
|
node_type,
|
|
81
82
|
start,
|
|
82
83
|
end - start,
|
|
83
|
-
this.lexer.
|
|
84
|
-
this.lexer.
|
|
84
|
+
this.lexer.token_line,
|
|
85
|
+
this.lexer.token_column
|
|
85
86
|
);
|
|
86
87
|
this.arena.set_content_length(node, end - start);
|
|
87
88
|
return node;
|
|
@@ -104,8 +105,8 @@ class ValueParser {
|
|
|
104
105
|
start,
|
|
105
106
|
0,
|
|
106
107
|
// length unknown yet
|
|
107
|
-
this.lexer.
|
|
108
|
-
this.lexer.
|
|
108
|
+
this.lexer.token_line,
|
|
109
|
+
this.lexer.token_column
|
|
109
110
|
);
|
|
110
111
|
this.arena.set_content_start_delta(node, 0);
|
|
111
112
|
this.arena.set_content_length(node, name_end - start);
|
|
@@ -153,9 +154,7 @@ class ValueParser {
|
|
|
153
154
|
let token_type = this.lexer.token_type;
|
|
154
155
|
if (token_type === TOKEN_EOF) break;
|
|
155
156
|
if (this.lexer.token_start >= this.value_end) break;
|
|
156
|
-
if (token_type ===
|
|
157
|
-
paren_depth++;
|
|
158
|
-
} else if (token_type === TOKEN_RIGHT_PAREN) {
|
|
157
|
+
if (token_type === TOKEN_RIGHT_PAREN) {
|
|
159
158
|
paren_depth--;
|
|
160
159
|
if (paren_depth === 0) {
|
|
161
160
|
content_end = this.lexer.token_start;
|
|
@@ -181,8 +180,8 @@ class ValueParser {
|
|
|
181
180
|
start,
|
|
182
181
|
0,
|
|
183
182
|
// length unknown yet
|
|
184
|
-
this.lexer.
|
|
185
|
-
this.lexer.
|
|
183
|
+
this.lexer.token_line,
|
|
184
|
+
this.lexer.token_column
|
|
186
185
|
);
|
|
187
186
|
let children = [];
|
|
188
187
|
let paren_depth = 1;
|
|
@@ -213,7 +212,7 @@ class ValueParser {
|
|
|
213
212
|
function parse_value(value_string) {
|
|
214
213
|
const arena = new CSSDataArena(CSSDataArena.capacity_for_source(value_string.length));
|
|
215
214
|
const value_parser = new ValueParser(arena, value_string);
|
|
216
|
-
const node_indices = value_parser.parse_value(0, value_string.length);
|
|
215
|
+
const node_indices = value_parser.parse_value(0, value_string.length, 1, 1);
|
|
217
216
|
return node_indices.map((index) => new CSSNode(arena, value_string, index));
|
|
218
217
|
}
|
|
219
218
|
|
package/dist/parse.js
CHANGED
|
@@ -213,6 +213,8 @@ class Parser {
|
|
|
213
213
|
this.arena.set_content_start_delta(declaration, 0);
|
|
214
214
|
this.arena.set_content_length(declaration, prop_end - prop_start);
|
|
215
215
|
let value_start = this.lexer.token_start;
|
|
216
|
+
let value_start_line = this.lexer.token_line;
|
|
217
|
+
let value_start_column = this.lexer.token_column;
|
|
216
218
|
let value_end = value_start;
|
|
217
219
|
let has_important = false;
|
|
218
220
|
let last_end = this.lexer.token_end;
|
|
@@ -242,7 +244,7 @@ class Parser {
|
|
|
242
244
|
this.arena.set_value_start_delta(declaration, trimmed[0] - prop_start);
|
|
243
245
|
this.arena.set_value_length(declaration, trimmed[1] - trimmed[0]);
|
|
244
246
|
if (this.parse_values_enabled && this.value_parser) {
|
|
245
|
-
let valueNodes = this.value_parser.parse_value(
|
|
247
|
+
let valueNodes = this.value_parser.parse_value(value_start, trimmed[1], value_start_line, value_start_column);
|
|
246
248
|
this.arena.append_children(declaration, valueNodes);
|
|
247
249
|
}
|
|
248
250
|
}
|
package/package.json
CHANGED