Commit a4e5075
authored
breaking: wrap declaration values in a Value node (#97)
BREAKING CHANGES:
- Declaration.value now returns VALUE node instead of raw string
- Declaration.values property removed
- Declaration.children now returns [VALUE] instead of value tokens
- parse_value() function returns CSSNode instead of CSSNode[]
Add VALUE node type (19) to wrap all declaration value tokens.
Each declaration now has a single VALUE child node that contains
the individual value tokens (IDENTIFIER, DIMENSION, etc.) as its
children.
Implementation changes:
- Add VALUE constant (19) in arena.ts
- Update NODES_PER_KB from 270 to 325 (+20% for VALUE wrappers)
- Modify CSSNode.value getter to return VALUE node for declarations
- Remove CSSNode.values getter (redundant)
- Update ValueParser.parse_value() to return single VALUE node
- Update DeclarationParser to create VALUE node for empty values
- Export VALUE from constants.ts
- Update 1068+ tests to use new API
Migration guide:
OLD: const text = declaration.value // "10px 20px"
OLD: const tokens = declaration.values // [DIMENSION, DIMENSION]
NEW: const valueNode = declaration.value // VALUE node
NEW: const text = valueNode.text // "10px 20px"
NEW: const tokens = valueNode.children // [DIMENSION, DIMENSION]1 parent ab661d7 commit a4e5075
File tree
12 files changed
+314
-277
lines changed- src
12 files changed
+314
-277
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
512 | | - | |
| 512 | + | |
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| |||
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
523 | | - | |
| 523 | + | |
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | | - | |
| 534 | + | |
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
| |||
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
545 | | - | |
| 545 | + | |
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
556 | | - | |
| 556 | + | |
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
567 | | - | |
| 567 | + | |
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
| |||
1028 | 1028 | | |
1029 | 1029 | | |
1030 | 1030 | | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
1035 | | - | |
1036 | | - | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
1037 | 1038 | | |
1038 | 1039 | | |
1039 | 1040 | | |
| |||
1042 | 1043 | | |
1043 | 1044 | | |
1044 | 1045 | | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
1048 | | - | |
1049 | | - | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
1050 | 1052 | | |
1051 | 1053 | | |
1052 | 1054 | | |
| |||
1055 | 1057 | | |
1056 | 1058 | | |
1057 | 1059 | | |
1058 | | - | |
1059 | | - | |
1060 | | - | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
1061 | 1064 | | |
1062 | | - | |
| 1065 | + | |
1063 | 1066 | | |
1064 | 1067 | | |
1065 | 1068 | | |
| |||
1093 | 1096 | | |
1094 | 1097 | | |
1095 | 1098 | | |
1096 | | - | |
| 1099 | + | |
1097 | 1100 | | |
1098 | 1101 | | |
1099 | 1102 | | |
| |||
1106 | 1109 | | |
1107 | 1110 | | |
1108 | 1111 | | |
1109 | | - | |
| 1112 | + | |
1110 | 1113 | | |
1111 | 1114 | | |
1112 | 1115 | | |
| |||
1213 | 1216 | | |
1214 | 1217 | | |
1215 | 1218 | | |
1216 | | - | |
| 1219 | + | |
1217 | 1220 | | |
1218 | | - | |
1219 | | - | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
1220 | 1225 | | |
1221 | 1226 | | |
1222 | 1227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
128 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
| 115 | + | |
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
| |||
240 | 243 | | |
241 | 244 | | |
242 | 245 | | |
243 | | - | |
| 246 | + | |
244 | 247 | | |
245 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
246 | 255 | | |
247 | 256 | | |
248 | 257 | | |
| |||
427 | 436 | | |
428 | 437 | | |
429 | 438 | | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | 439 | | |
444 | 440 | | |
445 | 441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
0 commit comments