@tbela99/css-parser 1.7.0 → 1.8.1
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/CHANGELOG.md +30 -0
- package/README.md +1 -0
- package/dist/index-umd-web.js +926 -293
- package/dist/index.cjs +925 -292
- package/dist/index.d.ts +251 -7
- package/dist/package.json.js +2 -2
- package/dist/src/data/properties.json.js +1 -1
- package/dist/src/data/validation.json.js +4 -1
- package/dist/src/lib/ast/clone.js +1 -1
- package/dist/src/lib/ast/expand.js +1 -1
- package/dist/src/lib/ast/features/calc.js +1 -1
- package/dist/src/lib/ast/features/if.js +1 -1
- package/dist/src/lib/ast/features/index.js +1 -1
- package/dist/src/lib/ast/features/inlinecssvariables.js +6 -5
- package/dist/src/lib/ast/features/prefix.js +1 -1
- package/dist/src/lib/ast/features/shorthand.js +1 -1
- package/dist/src/lib/ast/features/transform.js +1 -1
- package/dist/src/lib/ast/features/type.js +1 -1
- package/dist/src/lib/ast/find.js +26 -21
- package/dist/src/lib/ast/math/expression.js +4 -1
- package/dist/src/lib/ast/math/math.js +1 -1
- package/dist/src/lib/ast/minify.js +1 -1
- package/dist/src/lib/ast/node.js +1 -1
- package/dist/src/lib/ast/transform/compute.js +1 -1
- package/dist/src/lib/ast/transform/matrix.js +1 -1
- package/dist/src/lib/ast/transform/minify.js +1 -1
- package/dist/src/lib/ast/transform/perspective.js +1 -1
- package/dist/src/lib/ast/transform/rotate.js +1 -1
- package/dist/src/lib/ast/transform/scale.js +1 -1
- package/dist/src/lib/ast/transform/skew.js +1 -1
- package/dist/src/lib/ast/transform/translate.js +1 -1
- package/dist/src/lib/ast/transform/utils.js +1 -1
- package/dist/src/lib/ast/types.js +5 -1
- package/dist/src/lib/ast/walk.js +319 -94
- package/dist/src/lib/fs/resolve.js +1 -1
- package/dist/src/lib/parser/declaration/list.js +25 -1
- package/dist/src/lib/parser/declaration/map.js +1 -1
- package/dist/src/lib/parser/declaration/set.js +1 -1
- package/dist/src/lib/parser/linesmap.js +1 -1
- package/dist/src/lib/parser/parse.js +501 -165
- package/dist/src/lib/parser/source.js +1 -1
- package/dist/src/lib/parser/tokenize.js +23 -3
- package/dist/src/lib/parser/utils/angle.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-container.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-font-feature-values.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-generic.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-import.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-media.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-support.js +1 -1
- package/dist/src/lib/parser/utils/at-rule-when-else.js +1 -1
- package/dist/src/lib/parser/utils/at-rule.js +1 -1
- package/dist/src/lib/parser/utils/base64.js +1 -1
- package/dist/src/lib/parser/utils/cache.js +1 -1
- package/dist/src/lib/parser/utils/config.js +1 -1
- package/dist/src/lib/parser/utils/declaration.js +1 -1
- package/dist/src/lib/parser/utils/eq.js +1 -1
- package/dist/src/lib/parser/utils/hash.js +1 -1
- package/dist/src/lib/parser/utils/selector.js +1 -1
- package/dist/src/lib/parser/utils/text.js +1 -1
- package/dist/src/lib/parser/utils/token.js +12 -5
- package/dist/src/lib/parser/utils/type.js +1 -1
- package/dist/src/lib/printer/render.js +5 -2
- package/dist/src/lib/printer/sourcemap/lib/codec.js +1 -1
- package/dist/src/lib/printer/sourcemap/sourcemap.js +1 -1
- package/dist/src/lib/syntax/color/a98rgb.js +1 -1
- package/dist/src/lib/syntax/color/alpha.js +1 -1
- package/dist/src/lib/syntax/color/cmyk.js +1 -1
- package/dist/src/lib/syntax/color/color-mix.js +1 -1
- package/dist/src/lib/syntax/color/color.js +1 -1
- package/dist/src/lib/syntax/color/hex.js +1 -1
- package/dist/src/lib/syntax/color/hsl.js +1 -1
- package/dist/src/lib/syntax/color/hwb.js +1 -1
- package/dist/src/lib/syntax/color/lab.js +1 -1
- package/dist/src/lib/syntax/color/lch.js +1 -1
- package/dist/src/lib/syntax/color/oklab.js +1 -1
- package/dist/src/lib/syntax/color/oklch.js +1 -1
- package/dist/src/lib/syntax/color/p3.js +1 -1
- package/dist/src/lib/syntax/color/prophotorgb.js +1 -1
- package/dist/src/lib/syntax/color/rec2020.js +1 -1
- package/dist/src/lib/syntax/color/relative-color.js +1 -1
- package/dist/src/lib/syntax/color/rgb.js +1 -1
- package/dist/src/lib/syntax/color/srgb.js +1 -1
- package/dist/src/lib/syntax/color/utils/color-type.js +1 -1
- package/dist/src/lib/syntax/color/utils/colorspace.js +1 -1
- package/dist/src/lib/syntax/color/utils/components.js +1 -1
- package/dist/src/lib/syntax/color/utils/distance.js +1 -1
- package/dist/src/lib/syntax/color/utils/make-color.js +1 -1
- package/dist/src/lib/syntax/color/utils/matrix.js +1 -1
- package/dist/src/lib/syntax/color/xyz.js +1 -1
- package/dist/src/lib/syntax/color/xyzd50.js +1 -1
- package/dist/src/lib/syntax/constants.js +1 -1
- package/dist/src/lib/syntax/syntax.js +1 -1
- package/dist/src/lib/validation/config.js +1 -1
- package/dist/src/lib/validation/match.js +8 -5
- package/dist/src/lib/validation/parser/parse.js +1 -1
- package/dist/src/lib/validation/parser/typedef.js +1 -1
- package/dist/src/lib/validation/utils/list.js +1 -1
- package/dist/src/node.js +1 -1
- package/dist/src/types.js +1 -1
- package/dist/src/utils/sync.js +1 -1
- package/dist/src/web.js +1 -1
- package/package.json +4 -4
package/dist/src/lib/ast/node.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 1.
|
|
5
|
+
Version: 1.8.1
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
@@ -691,6 +691,10 @@ var EnumToken;
|
|
|
691
691
|
* CSS type token
|
|
692
692
|
*/
|
|
693
693
|
EnumToken[EnumToken["CssTypeTokenType"] = 144] = "CssTypeTokenType";
|
|
694
|
+
/**
|
|
695
|
+
* user defined dimension token type
|
|
696
|
+
*/
|
|
697
|
+
EnumToken[EnumToken["UserDefinedDimensionTokenType"] = 145] = "UserDefinedDimensionTokenType";
|
|
694
698
|
/* aliases */
|
|
695
699
|
/**
|
|
696
700
|
* alias for time token type
|
package/dist/src/lib/ast/walk.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 1.
|
|
5
|
+
Version: 1.8.1
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { PARENT, TOKENS } from '../syntax/constants.js';
|
|
9
|
+
import { EnumToken } from './types.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Options for the walk function
|
|
@@ -43,7 +44,6 @@ var WalkerEvent;
|
|
|
43
44
|
*/
|
|
44
45
|
WalkerEvent[WalkerEvent["Leave"] = 2] = "Leave";
|
|
45
46
|
})(WalkerEvent || (WalkerEvent = {}));
|
|
46
|
-
const maxQueueLength = 25000;
|
|
47
47
|
/**
|
|
48
48
|
* Walk ast nodes
|
|
49
49
|
* @param node initial node
|
|
@@ -126,7 +126,6 @@ function* walk(node, filter, reverse) {
|
|
|
126
126
|
let isNumeric = false;
|
|
127
127
|
let children = true;
|
|
128
128
|
let attributes = false;
|
|
129
|
-
let i = 0;
|
|
130
129
|
if (options != null && typeof options == "object") {
|
|
131
130
|
filter = options.filter;
|
|
132
131
|
reverse = options.reverse;
|
|
@@ -146,12 +145,11 @@ function* walk(node, filter, reverse) {
|
|
|
146
145
|
}
|
|
147
146
|
},
|
|
148
147
|
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
let option = null;
|
|
148
|
+
let option = null;
|
|
149
|
+
let source = [];
|
|
150
|
+
while (parents.length > 0) {
|
|
151
|
+
node = parents.pop();
|
|
152
|
+
// enter node
|
|
155
153
|
if (filter != null) {
|
|
156
154
|
// @ts-expect-error
|
|
157
155
|
option = filter(node);
|
|
@@ -172,36 +170,175 @@ function* walk(node, filter, reverse) {
|
|
|
172
170
|
yield result;
|
|
173
171
|
}
|
|
174
172
|
if (attributes) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
173
|
+
source.length = 0;
|
|
174
|
+
if (Array.isArray(node[TOKENS])) {
|
|
175
|
+
if (reverse) {
|
|
176
|
+
for (const token of node[TOKENS]) {
|
|
177
|
+
parents.push(token);
|
|
178
|
+
token[PARENT] = node;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
for (let i = node[TOKENS].length - 1; i >= 0; i--) {
|
|
183
|
+
parents.push(node[TOKENS][i]);
|
|
184
|
+
node[TOKENS][i][PARENT] = node;
|
|
181
185
|
}
|
|
182
186
|
}
|
|
183
|
-
// @ts-expect-error
|
|
184
187
|
}
|
|
185
|
-
else if (
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
else if (node.typ == EnumToken.DeclarationNodeType) {
|
|
189
|
+
if (reverse) {
|
|
190
|
+
for (const token of node.val) {
|
|
191
|
+
parents.push(token);
|
|
192
|
+
token[PARENT] = node;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
for (let i = node.val.length - 1; i >= 0; i--) {
|
|
197
|
+
parents.push(node.val[i]);
|
|
198
|
+
node.val[i][PARENT] = node;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
source.length = 0;
|
|
204
|
+
switch (node.typ) {
|
|
205
|
+
case EnumToken.BinaryExpressionTokenType:
|
|
206
|
+
case EnumToken.IfElseConditionTokenType:
|
|
207
|
+
source.push(node.l);
|
|
208
|
+
node.l[PARENT] = node;
|
|
209
|
+
source.push(node.r);
|
|
210
|
+
node.r[PARENT] = node;
|
|
211
|
+
break;
|
|
212
|
+
case EnumToken.MatchExpressionTokenType:
|
|
213
|
+
source.push(node.l);
|
|
214
|
+
node.l[PARENT] = node;
|
|
215
|
+
source.push(node.op);
|
|
216
|
+
node.op[PARENT] = node;
|
|
217
|
+
source.push(node.r);
|
|
218
|
+
node.r[PARENT] = node;
|
|
219
|
+
break;
|
|
220
|
+
case EnumToken.SupportsQueryConditionTokenType:
|
|
221
|
+
case EnumToken.MediaQueryConditionTokenType:
|
|
222
|
+
for (let i = 0; i < node.l.length; i++) {
|
|
223
|
+
const element = node.l[i];
|
|
224
|
+
source.push(element);
|
|
225
|
+
element[PARENT] = node;
|
|
226
|
+
}
|
|
227
|
+
source.push(node.op);
|
|
228
|
+
node.op[PARENT] = node;
|
|
229
|
+
for (let i = 0; i < node.r.length; i++) {
|
|
230
|
+
const element = node.r[i];
|
|
231
|
+
source.push(element);
|
|
232
|
+
element[PARENT] = node;
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
case EnumToken.WhenElseQueryConditionTokenType:
|
|
236
|
+
source.push(node.l);
|
|
237
|
+
node.l[PARENT] = node;
|
|
238
|
+
for (let i = 0; i < node.r.length; i++) {
|
|
239
|
+
const element = node.r[i];
|
|
240
|
+
source.push(element);
|
|
241
|
+
element[PARENT] = node;
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
case EnumToken.ComposesSelectorNodeType:
|
|
245
|
+
for (let i = 0; i < node.l.length; i++) {
|
|
246
|
+
const element = node.l[i];
|
|
247
|
+
source.push(element);
|
|
248
|
+
element[PARENT] = node;
|
|
249
|
+
}
|
|
250
|
+
if (node.r != null) {
|
|
251
|
+
source.push(node.r);
|
|
252
|
+
node.r[PARENT] = node;
|
|
253
|
+
}
|
|
254
|
+
break;
|
|
255
|
+
case EnumToken.IfConditionTokenType:
|
|
256
|
+
for (let i = 0; i < node.l.length; i++) {
|
|
257
|
+
const element = node.l[i];
|
|
258
|
+
source.push(element);
|
|
259
|
+
element[PARENT] = node;
|
|
260
|
+
}
|
|
261
|
+
for (let i = 0; i < node.r.length; i++) {
|
|
262
|
+
const element = node.r[i];
|
|
263
|
+
source.push(element);
|
|
264
|
+
element[PARENT] = node;
|
|
265
|
+
}
|
|
266
|
+
break;
|
|
267
|
+
case EnumToken.ContainerStyleRangeTokenType:
|
|
268
|
+
for (let i = 0; i < node.l.length; i++) {
|
|
269
|
+
const element = node.l[i];
|
|
270
|
+
source.push(element);
|
|
271
|
+
element[PARENT] = node;
|
|
272
|
+
}
|
|
273
|
+
for (let i = 0; i < node.op.length; i++) {
|
|
274
|
+
const element = node.op[i];
|
|
275
|
+
source.push(element);
|
|
276
|
+
element[PARENT] = node;
|
|
277
|
+
}
|
|
278
|
+
for (let i = 0; i < node.r.length; i++) {
|
|
279
|
+
const element = node.r[i];
|
|
280
|
+
source.push(element);
|
|
281
|
+
element[PARENT] = node;
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
case EnumToken.MediaRangeQueryTokenType:
|
|
285
|
+
for (let i = 0; i < node.l.length; i++) {
|
|
286
|
+
const element = node.l[i];
|
|
287
|
+
source.push(element);
|
|
288
|
+
element[PARENT] = node;
|
|
289
|
+
}
|
|
290
|
+
source.push(node.op1);
|
|
291
|
+
node.op1[PARENT] = node;
|
|
292
|
+
for (let i = 0; i < node.val.length; i++) {
|
|
293
|
+
const element = node.val[i];
|
|
294
|
+
source.push(element);
|
|
295
|
+
element[PARENT] = node;
|
|
296
|
+
}
|
|
297
|
+
source.push(node.op2);
|
|
298
|
+
node.op2[PARENT] = node;
|
|
299
|
+
for (let i = 0; i < node.r.length; i++) {
|
|
300
|
+
const element = node.r[i];
|
|
301
|
+
source.push(element);
|
|
302
|
+
element[PARENT] = node;
|
|
303
|
+
}
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
if (source.length > 0) {
|
|
307
|
+
if (reverse) {
|
|
308
|
+
for (let i = 0; i < source.length; i++) {
|
|
309
|
+
parents.push(source[i]);
|
|
310
|
+
source[i][PARENT] = node;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
for (let i = source.length - 1; i >= 0; i--) {
|
|
315
|
+
parents.push(source[i]);
|
|
316
|
+
source[i][PARENT] = node;
|
|
317
|
+
}
|
|
190
318
|
}
|
|
191
319
|
}
|
|
192
|
-
// @ts-expect-error
|
|
193
|
-
parents.splice(i, 0, ...(reverse ? node.val.toReversed() : node.val));
|
|
194
320
|
}
|
|
195
321
|
}
|
|
196
322
|
if (children &&
|
|
197
323
|
// @ts-expect-error
|
|
198
324
|
node["chi"] != null &&
|
|
199
325
|
(!isNumeric || (option & WalkerOptionEnum.IgnoreChildren) === 0)) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
326
|
+
if (reverse) {
|
|
327
|
+
// @ts-expect-error
|
|
328
|
+
for (let i = 0; i < node.chi.length; i++) {
|
|
329
|
+
// @ts-expect-error
|
|
330
|
+
parents.push(node.chi[i]);
|
|
331
|
+
// @ts-expect-error
|
|
332
|
+
node.chi[i][PARENT] = node;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
// @ts-expect-error
|
|
337
|
+
for (let i = node.chi.length - 1; i >= 0; i--) {
|
|
338
|
+
// @ts-expect-error
|
|
339
|
+
parents.push(node.chi[i]);
|
|
340
|
+
// @ts-expect-error
|
|
341
|
+
node.chi[i][PARENT] = node;
|
|
205
342
|
}
|
|
206
343
|
}
|
|
207
344
|
}
|
|
@@ -254,9 +391,19 @@ function* walk(node, filter, reverse) {
|
|
|
254
391
|
* // [ "Iden", "from" ]
|
|
255
392
|
* ```
|
|
256
393
|
*/
|
|
257
|
-
function* walkValues(
|
|
258
|
-
const
|
|
394
|
+
function* walkValues(tokens, root = null, filter, reverse) {
|
|
395
|
+
const nodes = [];
|
|
259
396
|
let previous = null;
|
|
397
|
+
if (reverse) {
|
|
398
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
399
|
+
nodes.push(tokens[i]);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
404
|
+
nodes.push(tokens[i]);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
260
407
|
if (filter != null && typeof filter == "function") {
|
|
261
408
|
filter = {
|
|
262
409
|
event: WalkerEvent.Enter,
|
|
@@ -272,7 +419,7 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
272
419
|
let value;
|
|
273
420
|
let option;
|
|
274
421
|
let node;
|
|
275
|
-
|
|
422
|
+
const values = [];
|
|
276
423
|
const eventType = filter.event ?? WalkerEvent.Enter;
|
|
277
424
|
// @ts-ignore
|
|
278
425
|
const result = {
|
|
@@ -291,13 +438,9 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
291
438
|
}
|
|
292
439
|
},
|
|
293
440
|
};
|
|
294
|
-
while (
|
|
295
|
-
value =
|
|
441
|
+
while (nodes.length > 0) {
|
|
442
|
+
value = nodes.pop();
|
|
296
443
|
option = null;
|
|
297
|
-
if (i > maxQueueLength) {
|
|
298
|
-
stack.splice(0, maxQueueLength);
|
|
299
|
-
i -= maxQueueLength;
|
|
300
|
-
}
|
|
301
444
|
if (filter.fn != null && eventType & WalkerEvent.Enter) {
|
|
302
445
|
const isValid = filter.type == null ||
|
|
303
446
|
value.typ == filter.type ||
|
|
@@ -325,10 +468,16 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
325
468
|
//
|
|
326
469
|
if (option != null && typeof option == "object" && ("typ" in option || Array.isArray(option))) {
|
|
327
470
|
const op = Array.isArray(option) ? option : [option];
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
471
|
+
if (reverse) {
|
|
472
|
+
for (let i = 0; i < op.length; i++) {
|
|
473
|
+
nodes.push(op[i]);
|
|
474
|
+
op[i][PARENT] = value;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
for (let i = op.length - 1; i >= 0; i--) {
|
|
479
|
+
nodes.push(op[i]);
|
|
480
|
+
op[i][PARENT] = value;
|
|
332
481
|
}
|
|
333
482
|
}
|
|
334
483
|
}
|
|
@@ -337,70 +486,140 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
337
486
|
result.value = value;
|
|
338
487
|
result.parent = value[PARENT] ?? root;
|
|
339
488
|
result.previousValue = previous;
|
|
340
|
-
result.nextValue =
|
|
489
|
+
result.nextValue = nodes[nodes.length - 1] ?? null;
|
|
341
490
|
yield result;
|
|
342
491
|
if (!isNumeric || (option & WalkerOptionEnum.IgnoreChildren) === 0) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
492
|
+
//
|
|
493
|
+
if (value.chi != null) {
|
|
494
|
+
const source = value.chi;
|
|
495
|
+
if (reverse) {
|
|
496
|
+
for (let i = 0; i < source.length; i++) {
|
|
497
|
+
nodes.push(source[i]);
|
|
498
|
+
source[i][PARENT] = value;
|
|
348
499
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
for (let i = source.length - 1; i >= 0; i--) {
|
|
503
|
+
nodes.push(source[i]);
|
|
504
|
+
source[i][PARENT] = value;
|
|
354
505
|
}
|
|
355
506
|
}
|
|
356
507
|
}
|
|
357
508
|
else {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (value.l[PARENT] != value) {
|
|
364
|
-
// @ts-expect-error
|
|
509
|
+
values.length = 0;
|
|
510
|
+
switch (value.typ) {
|
|
511
|
+
case EnumToken.BinaryExpressionTokenType:
|
|
512
|
+
case EnumToken.IfElseConditionTokenType:
|
|
513
|
+
values.push(value.l);
|
|
365
514
|
value.l[PARENT] = value;
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
// @ts-expect-error
|
|
515
|
+
values.push(value.r);
|
|
516
|
+
value.r[PARENT] = value;
|
|
517
|
+
break;
|
|
518
|
+
case EnumToken.MatchExpressionTokenType:
|
|
519
|
+
values.push(value.l);
|
|
520
|
+
value.l[PARENT] = value;
|
|
521
|
+
values.push(value.op);
|
|
374
522
|
value.op[PARENT] = value;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
if ("r" in value && value.r != null) {
|
|
378
|
-
if (Array.isArray(value.r)) {
|
|
379
|
-
for (const r of value.r) {
|
|
380
|
-
//
|
|
381
|
-
values.push(r);
|
|
382
|
-
if (r[PARENT] != value) {
|
|
383
|
-
//
|
|
384
|
-
r[PARENT] = value;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
//
|
|
390
523
|
values.push(value.r);
|
|
391
|
-
|
|
392
|
-
|
|
524
|
+
value.r[PARENT] = value;
|
|
525
|
+
break;
|
|
526
|
+
case EnumToken.SupportsQueryConditionTokenType:
|
|
527
|
+
case EnumToken.MediaQueryConditionTokenType:
|
|
528
|
+
for (let i = 0; i < value.l.length; i++) {
|
|
529
|
+
const element = value.l[i];
|
|
530
|
+
values.push(element);
|
|
531
|
+
element[PARENT] = value;
|
|
532
|
+
}
|
|
533
|
+
values.push(value.op);
|
|
534
|
+
value.op[PARENT] = value;
|
|
535
|
+
for (let i = 0; i < value.r.length; i++) {
|
|
536
|
+
const element = value.r[i];
|
|
537
|
+
values.push(element);
|
|
538
|
+
element[PARENT] = value;
|
|
539
|
+
}
|
|
540
|
+
break;
|
|
541
|
+
case EnumToken.ComposesSelectorNodeType:
|
|
542
|
+
for (let i = 0; i < value.l.length; i++) {
|
|
543
|
+
const element = value.l[i];
|
|
544
|
+
values.push(element);
|
|
545
|
+
element[PARENT] = value;
|
|
546
|
+
}
|
|
547
|
+
if (value.r != null) {
|
|
548
|
+
values.push(value.r);
|
|
393
549
|
value.r[PARENT] = value;
|
|
394
550
|
}
|
|
395
|
-
|
|
551
|
+
break;
|
|
552
|
+
case EnumToken.WhenElseQueryConditionTokenType:
|
|
553
|
+
values.push(value.l);
|
|
554
|
+
value.l[PARENT] = value;
|
|
555
|
+
for (let i = 0; i < value.r.length; i++) {
|
|
556
|
+
const element = value.r[i];
|
|
557
|
+
values.push(element);
|
|
558
|
+
element[PARENT] = value;
|
|
559
|
+
}
|
|
560
|
+
break;
|
|
561
|
+
case EnumToken.IfConditionTokenType:
|
|
562
|
+
for (let i = 0; i < value.l.length; i++) {
|
|
563
|
+
const element = value.l[i];
|
|
564
|
+
values.push(element);
|
|
565
|
+
element[PARENT] = value;
|
|
566
|
+
}
|
|
567
|
+
for (let i = 0; i < value.r.length; i++) {
|
|
568
|
+
const element = value.r[i];
|
|
569
|
+
values.push(element);
|
|
570
|
+
element[PARENT] = value;
|
|
571
|
+
}
|
|
572
|
+
break;
|
|
573
|
+
case EnumToken.ContainerStyleRangeTokenType:
|
|
574
|
+
for (let i = 0; i < value.l.length; i++) {
|
|
575
|
+
const element = value.l[i];
|
|
576
|
+
values.push(element);
|
|
577
|
+
element[PARENT] = value;
|
|
578
|
+
}
|
|
579
|
+
for (let i = 0; i < value.op.length; i++) {
|
|
580
|
+
const element = value.op[i];
|
|
581
|
+
values.push(element);
|
|
582
|
+
element[PARENT] = value;
|
|
583
|
+
}
|
|
584
|
+
for (let i = 0; i < value.r.length; i++) {
|
|
585
|
+
const element = value.r[i];
|
|
586
|
+
values.push(element);
|
|
587
|
+
element[PARENT] = value;
|
|
588
|
+
}
|
|
589
|
+
break;
|
|
590
|
+
case EnumToken.MediaRangeQueryTokenType:
|
|
591
|
+
for (let i = 0; i < value.l.length; i++) {
|
|
592
|
+
const element = value.l[i];
|
|
593
|
+
values.push(element);
|
|
594
|
+
element[PARENT] = value;
|
|
595
|
+
}
|
|
596
|
+
values.push(value.op1);
|
|
597
|
+
value.op1[PARENT] = value;
|
|
598
|
+
for (let i = 0; i < value.val.length; i++) {
|
|
599
|
+
const element = value.val[i];
|
|
600
|
+
values.push(element);
|
|
601
|
+
element[PARENT] = value;
|
|
602
|
+
}
|
|
603
|
+
values.push(value.op2);
|
|
604
|
+
value.op2[PARENT] = value;
|
|
605
|
+
for (let i = 0; i < value.r.length; i++) {
|
|
606
|
+
const element = value.r[i];
|
|
607
|
+
values.push(element);
|
|
608
|
+
element[PARENT] = value;
|
|
609
|
+
}
|
|
610
|
+
break;
|
|
396
611
|
}
|
|
397
612
|
if (values.length > 0) {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
613
|
+
if (reverse) {
|
|
614
|
+
for (let i = 0; i < values.length; i++) {
|
|
615
|
+
nodes.push(values[i]);
|
|
616
|
+
values[i][PARENT] = value;
|
|
401
617
|
}
|
|
402
|
-
|
|
403
|
-
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
for (let i = values.length - 1; i >= 0; i--) {
|
|
621
|
+
nodes.push(values[i]);
|
|
622
|
+
values[i][PARENT] = value;
|
|
404
623
|
}
|
|
405
624
|
}
|
|
406
625
|
}
|
|
@@ -417,10 +636,16 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
417
636
|
// @ts-ignore
|
|
418
637
|
if (option != null && ("typ" in option || Array.isArray(option))) {
|
|
419
638
|
const op = Array.isArray(option) ? option : [option];
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
639
|
+
if (reverse) {
|
|
640
|
+
for (let i = 0; i < op.length; i++) {
|
|
641
|
+
nodes.push(op[i]);
|
|
642
|
+
op[i][PARENT] = value;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
for (let i = op.length - 1; i >= 0; i--) {
|
|
647
|
+
nodes.push(op[i]);
|
|
648
|
+
op[i][PARENT] = value;
|
|
424
649
|
}
|
|
425
650
|
}
|
|
426
651
|
}
|