Repository navigation
Expand file tree
/
Copy pathdata.js
More file actions
9811 lines (9621 loc) · 327 KB
/
Copy pathdata.js
File metadata and controls
9811 lines (9621 loc) · 327 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author sheo13666q @sheo13666q
*/
// GENERATED by tooling/generate-css-data.js — do not edit.
// Sources: mdn-data, color-name and @mdn/browser-compat-data, at the versions yarn.lock pins.
"use strict";
const memoize = require("../util/memoize");
// Tables only the minifier or a `css/module` reads are getters built on first use,
// so a build parsing CSS without them never compiles or allocates them.
/** @typedef {(sums: Map<string, number>[]) => [string, number[]] | null} MathArgumentReader */
/** @typedef {(values: number[], strategy: string, table: Map<number, number>) => number | null} MathOperation */
// WHY: The arithmetic the math-function descriptors at the end of this file bind to.
// It knows nothing of CSS beyond the shape of an evaluated argument, and names
// no math function: which one uses which is the descriptors' business, and
// `lib/css/syntax.js` only drives the binding.
/**
* Add two doubles, or decline when the sum carries rounding of its own.
* @param {number} a one term
* @param {number} b the other
* @returns {number | null} their exact sum, or `null`
*/
const exactAdd = (a, b) => {
const sum = a + b;
return sum - b === a && sum - a === b ? sum : null;
};
/**
* Multiply, or decline, on the same terms.
* @param {number} a the value
* @param {number} k the factor
* @returns {number | null} their exact product, or `null`
*/
const exactMultiply = (a, k) => {
const product = a * k;
if (!Number.isFinite(product)) return null;
if (a === 0 || k === 0) return product;
return product / k === a ? product : null;
};
/**
* Add two doubles. Every sum a stylesheet can write is finite, and one that is
* not is no value to print.
* @param {number} a one term
* @param {number} b the other
* @returns {number | null} their sum, or `null`
*/
const foldAdd = (a, b) => {
const sum = a + b;
return Number.isFinite(sum) ? sum : null;
};
/**
* @param {number} a the value
* @param {number} k the factor
* @returns {number | null} their product, or `null`
*/
const foldMultiply = (a, k) => {
const product = a * k;
return Number.isFinite(product) ? product : null;
};
/**
* @param {number} a the value
* @param {number} k the divisor
* @returns {number | null} their quotient, or `null` where there is none
*/
const foldDivide = (a, k) => {
if (k === 0) return null;
const quotient = a / k;
return Number.isFinite(quotient) ? quotient : null;
};
/**
* `floor(value / step)` for a positive step, checked against the step exactly.
* The double quotient can land an ulp either side of an integer, which would put
* the multiple a whole step out, so the candidate is verified by multiplying
* back and nudged at most once either way.
* @param {number} value the dividend
* @param {number} step the divisor, greater than zero
* @returns {number | null} the floor, or `null` when it cannot be pinned down
*/
const exactFloorDivide = (value, step) => {
let n = Math.floor(value / step);
if (!Number.isFinite(n)) return null;
for (let attempt = 0; attempt < 3; attempt++) {
const at = exactMultiply(n, step);
const next = exactMultiply(n + 1, step);
if (at === null || next === null) return null;
if (at > value) {
n--;
continue;
}
if (next <= value) {
n++;
continue;
}
return n;
}
return null;
};
/**
* One evaluated argument list, read as a shared unit and its coefficients. A
* percentage is refused: its basis can be negative (a `background-position`
* against an image wider than its box), and comparing two of them depends on
* that sign in a way `calc()`'s arithmetic does not — scaling a percentage is
* linear, picking the smaller of two is not.
* @param {Map<string, number>[]} sums the evaluated arguments
* @returns {[string, number[]] | null} the shared unit and the coefficients
*/
const readSameUnit = (sums) => {
/** @type {string | null} */
let shared = null;
/** @type {number[]} */
const values = [];
for (const sum of sums) {
if (sum.size !== 1) return null;
const [[key, coefficient]] = sum;
if (key === "%") return null;
if (shared === null) shared = key;
else if (shared !== key) return null;
values.push(coefficient);
}
return shared === null ? null : [shared, values];
};
/**
* The same, narrowed to arguments that reduced to a plain `<number>`.
* @param {Map<string, number>[]} sums the evaluated arguments
* @returns {[string, number[]] | null} the unit (always `""`) and the numbers
*/
const readNumber = (sums) => {
const shared = readSameUnit(sums);
return shared === null || shared[0] !== "" ? null : shared;
};
/**
* Read a trigonometric function's one argument as degrees. A bare number is
* radians (CSS Values 4 §10.6), and an angle is the unit it was written in;
* either way what the fold needs is the one measure the tables are keyed by.
* @param {Map<string, number>} quarterTurnAngle a quarter turn in each unit that spells one exactly
* @returns {MathArgumentReader} the reader
*/
const angleReader = (quarterTurnAngle) => (sums) => {
const shared = readSameUnit(sums);
if (shared === null) return null;
const [unit, [angle]] = shared;
// A radian is what a bare number is read as, and the one angle unit that
// spells no quarter turn exactly — so the table states none for it.
if (unit === "" || unit === "rad") return ["", [(angle * 180) / Math.PI]];
const quarter = quarterTurnAngle.get(unit);
if (quarter === undefined) return null;
return ["", [(angle * 90) / quarter]];
};
/**
* @param {number[]} values the coefficients
* @returns {number} the smallest
*/
const minimum = (values) => Math.min(...values);
/**
* @param {number[]} values the coefficients
* @returns {number} the largest
*/
const maximum = (values) => Math.max(...values);
/**
* CSS Values 4 §10.4: the lower bound wins a contradictory pair.
* @param {number[]} values the lower bound, the value and the upper bound
* @returns {number} the value held between them
*/
const clamp = ([lower, value, upper]) =>
Math.max(lower, Math.min(value, upper));
/**
* @param {number[]} values the one coefficient
* @returns {number} its magnitude
*/
const absolute = ([value]) => Math.abs(value);
/**
* The one operation whose answer changes unit: a sign is a `<number>`. Every
* unit reaching here scales by a positive factor, so the coefficient's sign is
* the value's even where the factor is not known.
* @param {number[]} values the one coefficient
* @returns {number} its sign
*/
const sign = ([value]) => Math.sign(value);
/**
* @param {number[]} values the coefficients
* @returns {number | null} the root of their squares, or `null`
*/
const hypotenuse = (values) => {
const total = Math.hypot(...values);
return Number.isFinite(total) ? total : null;
};
/**
* The multiple of `step` that `strategy` rounds `value` to, as CSS Values 4
* §10.6 defines them and headless Chromium confirms: `nearest` breaks a tie
* toward positive infinity, and the other three are the ceiling, the floor and
* the truncation. A step of zero is NaN per the spec and engines do not agree
* on what that renders as; a negative one is left alone rather than reasoned
* about.
* @param {number[]} values the value and the step
* @param {string} strategy one of the grammar's rounding strategies
* @returns {number | null} the rounded multiple, or `null`
*/
const round = ([value, step], strategy) => {
if (!(step > 0)) return null;
const below = exactFloorDivide(value, step);
if (below === null) return null;
const at = /** @type {number} */ (exactMultiply(below, step));
// WHY: Exactly on a step is where engines stop agreeing: these are step functions,
// so an ulp of error in the engine's own conversion moves the answer a whole
// step. Headless Chromium reads `round(down,10cm,2cm)` as `8cm` and
// `round(down,-7cm,.5cm)` as `-7.5cm`. Away from a boundary the gap is orders
// of magnitude wider than any such error, so only the boundary is refused.
if (at === value) return null;
let multiple;
if (strategy === "down") {
multiple = below;
} else if (strategy === "up") {
multiple = below + 1;
} else if (strategy === "to-zero") {
multiple = value < 0 ? below + 1 : below;
} else {
// The remainder is in `[0, step)`, so twice it against the step is the
// comparison, and an exact half rounds up — toward positive infinity.
const remainder = exactAdd(value, -at);
if (remainder === null) return null;
const doubled = exactMultiply(remainder, 2);
if (doubled === null) return null;
multiple = doubled >= step ? below + 1 : below;
}
return exactMultiply(multiple, step);
};
/**
* The remainder carrying the divisor's sign.
* @param {number[]} values the dividend and the divisor
* @returns {number | null} the remainder, or `null`
*/
const modulus = ([value, divisor]) => {
if (divisor === 0) return null;
const remainder = value % divisor;
// A zero remainder is the boundary these two share with `round()`, and engines
// do not agree on it: headless Chromium reads `mod(10px,-2px)` and
// `mod(-9px,3px)` as the divisor where both are zero.
if (remainder === 0) return null;
// A remainder on the other side of zero is brought back across it.
return remainder < 0 === divisor < 0
? remainder
: exactAdd(remainder, divisor);
};
/**
* The remainder carrying the dividend's sign, which is what `%` already does.
* @param {number[]} values the dividend and the divisor
* @returns {number | null} the remainder, or `null`
*/
const remainder = ([value, divisor]) => {
if (divisor === 0) return null;
// The same zero boundary `modulus` declines.
const rest = value % divisor;
return rest === 0 ? null : rest;
};
/**
* @param {number[]} values the one radicand
* @returns {number | null} its root, or `null` where there is none
*/
const squareRoot = ([value]) => (value >= 0 ? Math.sqrt(value) : null);
/**
* @param {number[]} values the base and the exponent
* @returns {number | null} the power, or `null`
*/
const power = ([base, exponent]) => {
const raised = base ** exponent;
return Number.isFinite(raised) ? raised : null;
};
/**
* @param {number[]} values the value and, optionally, the base
* @returns {number | null} the logarithm, or `null` where there is none
*/
const logarithm = ([value, base]) => {
if (!(value > 0)) return null;
if (base === undefined) return Math.log(value);
// A base of one divides by zero and a negative one has no logarithm at all;
// both leave a quotient that is not a number.
const quotient = Math.log(value) / Math.log(base);
return Number.isFinite(quotient) ? quotient : null;
};
/**
* @param {number[]} values the one exponent
* @returns {number | null} `e` raised to it, or `null`
*/
const exponential = ([value]) => {
const raised = Math.exp(value);
return Number.isFinite(raised) ? raised : null;
};
/**
* The value a table gives at a whole number of eighth turns, where a real
* computation would answer an ulp away from it — `Math.sin(Math.PI)` is 1.2e-16
* rather than the zero the table states.
* @param {number} degrees the angle
* @param {Map<number, number>} table the function's eighth-turn table
* @returns {number | undefined} the stated value, or undefined
*/
const eighthTurn = (degrees, table) => {
const eighths = degrees / 45;
return Number.isInteger(eighths)
? table.get(((eighths % 8) + 8) % 8)
: undefined;
};
/**
* An inverse trigonometric function answers with an angle, and an angle is the
* one thing the printer does not round — a `rotate()` runs it back through trig,
* where a truncated digit is a different matrix. So only the arguments the table
* states are taken: everywhere else the real answer carries digits that are
* noise (`asin(.5)` is 30.000000000000004 degrees) and no shorter than the call.
* @param {number[]} values the one argument
* @param {string} keyword unused
* @param {Map<number, number>} table the arguments the table states
* @returns {number | null} the angle in degrees, or `null`
*/
const statedAngle = ([value], keyword, table) => {
const stated = table.get(value);
return stated === undefined ? null : stated;
};
/**
* Tangent, which has an asymptote an odd quarter turn from zero: the table
* states no value there because there is none, and a double still answers with
* a very large one.
* @param {number[]} values the angle in degrees
* @param {string} keyword unused
* @param {Map<number, number>} table the eighth-turn table
* @returns {number | null} its tangent, or `null` at an asymptote
*/
const tangent = ([degrees], keyword, table) => {
const stated = eighthTurn(degrees, table);
if (stated !== undefined) return stated;
const quarters = degrees / 90;
if (Number.isInteger(quarters) && ((quarters % 2) + 2) % 2 === 1) return null;
return Math.tan((degrees * Math.PI) / 180);
};
/**
* @param {number[]} values the angle in degrees
* @param {string} keyword unused
* @param {Map<number, number>} table the eighth-turn table
* @returns {number | null} its cosine
*/
const cosine = ([degrees], keyword, table) => {
const stated = eighthTurn(degrees, table);
return stated === undefined ? Math.cos((degrees * Math.PI) / 180) : stated;
};
/**
* @param {number[]} values the angle in degrees
* @param {string} keyword unused
* @param {Map<number, number>} table the eighth-turn table
* @returns {number | null} its sine
*/
const sine = ([degrees], keyword, table) => {
const stated = eighthTurn(degrees, table);
return stated === undefined ? Math.sin((degrees * Math.PI) / 180) : stated;
};
/**
* The eight directions the arc tangent of a ratio is a whole number of degrees
* in, an eighth turn apart. Both zero is refused: the spec leaves it to the
* engine.
* @param {number[]} values the two coordinates
* @returns {number | null} the angle in degrees, or `null`
*/
const arcTangent2 = ([y, x]) => {
if (y === 0 && x === 0) return null;
if (y === 0) return x > 0 ? 0 : 180;
if (x === 0) return y > 0 ? 90 : -90;
if (Math.abs(y) !== Math.abs(x)) return null;
if (x > 0) return y > 0 ? 45 : -45;
return y > 0 ? 135 : -135;
};
// WHY: Properties whose value is CSS's `{1,4}` box notation, where an omitted value
// is copied from the opposite side. That makes a repeated value redundant:
// `margin:1px 1px 1px 1px` is `margin:1px`. `border-radius` collapses each side
// of its `/` independently.
const BOX_SHORTHANDS = new Set([
"border-color",
"border-image-outset",
"border-image-width",
"border-radius",
"border-style",
"border-width",
"corner-shape",
"inset",
"margin",
"mask-border-outset",
"mask-border-width",
"padding",
"scroll-margin",
"scroll-padding"
]);
// The subset carrying a second box after a `/`, which collapses on its own.
const SLASH_BOX_SHORTHANDS = new Set(["border-radius"]);
// WHY: The four longhands each box shorthand sets, in the order `{1,4}` writes them:
// `top right bottom left`, or clockwise from the top left for a corner family.
// Only the families whose longhands are those four: merging those into the
// shorthand sets exactly the same properties, resetting nothing extra.
// prettier-ignore
const BOX_LONGHANDS = new Map([
["border-color", ["border-top-color", "border-right-color", "border-bottom-color", "border-left-color"]],
["border-radius", ["border-top-left-radius", "border-top-right-radius", "border-bottom-right-radius", "border-bottom-left-radius"]],
["border-style", ["border-top-style", "border-right-style", "border-bottom-style", "border-left-style"]],
["border-width", ["border-top-width", "border-right-width", "border-bottom-width", "border-left-width"]],
["corner-shape", ["corner-top-left-shape", "corner-top-right-shape", "corner-bottom-right-shape", "corner-bottom-left-shape"]],
["inset", ["top", "right", "bottom", "left"]],
["margin", ["margin-top", "margin-right", "margin-bottom", "margin-left"]],
["padding", ["padding-top", "padding-right", "padding-bottom", "padding-left"]],
["scroll-margin", ["scroll-margin-top", "scroll-margin-right", "scroll-margin-bottom", "scroll-margin-left"]],
["scroll-padding", ["scroll-padding-top", "scroll-padding-right", "scroll-padding-bottom", "scroll-padding-left"]]
]);
// The shorthands setting exactly two longhands, positionally — the same merge
// as the box families, two values wide. Only these: a shorthand gathering a
// whole family resets longhands `computed` does not name.
const PAIR_LONGHANDS = new Map([
[
"border-block-color",
["border-block-start-color", "border-block-end-color"]
],
[
"border-block-style",
["border-block-start-style", "border-block-end-style"]
],
[
"border-block-width",
["border-block-start-width", "border-block-end-width"]
],
[
"border-inline-color",
["border-inline-start-color", "border-inline-end-color"]
],
[
"border-inline-style",
["border-inline-start-style", "border-inline-end-style"]
],
[
"border-inline-width",
["border-inline-start-width", "border-inline-end-width"]
],
[
"contain-intrinsic-size",
["contain-intrinsic-width", "contain-intrinsic-height"]
],
[
"corner-block-end-shape",
["corner-end-start-shape", "corner-end-end-shape"]
],
[
"corner-block-start-shape",
["corner-start-start-shape", "corner-start-end-shape"]
],
[
"corner-bottom-shape",
["corner-bottom-left-shape", "corner-bottom-right-shape"]
],
[
"corner-inline-end-shape",
["corner-start-end-shape", "corner-end-end-shape"]
],
[
"corner-inline-start-shape",
["corner-start-start-shape", "corner-end-start-shape"]
],
["corner-left-shape", ["corner-top-left-shape", "corner-bottom-left-shape"]],
[
"corner-right-shape",
["corner-top-right-shape", "corner-bottom-right-shape"]
],
["corner-top-shape", ["corner-top-left-shape", "corner-top-right-shape"]],
["gap", ["row-gap", "column-gap"]],
["inset-block", ["inset-block-start", "inset-block-end"]],
["inset-inline", ["inset-inline-start", "inset-inline-end"]],
["interest-delay", ["interest-delay-start", "interest-delay-end"]],
["margin-block", ["margin-block-start", "margin-block-end"]],
["margin-inline", ["margin-inline-start", "margin-inline-end"]],
["overflow", ["overflow-x", "overflow-y"]],
["overscroll-behavior", ["overscroll-behavior-x", "overscroll-behavior-y"]],
["padding-block", ["padding-block-start", "padding-block-end"]],
["padding-inline", ["padding-inline-start", "padding-inline-end"]],
["place-content", ["align-content", "justify-content"]],
["place-items", ["align-items", "justify-items"]],
["place-self", ["align-self", "justify-self"]],
[
"scroll-margin-block",
["scroll-margin-block-start", "scroll-margin-block-end"]
],
[
"scroll-margin-inline",
["scroll-margin-inline-start", "scroll-margin-inline-end"]
],
[
"scroll-padding-block",
["scroll-padding-block-start", "scroll-padding-block-end"]
],
[
"scroll-padding-inline",
["scroll-padding-inline-start", "scroll-padding-inline-end"]
]
]);
// The subset whose two-value form is newer than the longhands, so only a merge
// collapsing to one value may emit it.
const ONE_VALUE_PAIR_SHORTHANDS = new Set(["overflow"]);
// The pair shorthands the target's `placeShorthand` ability gates, newer than
// the longhands they merge.
const PLACE_SHORTHANDS = new Set([
"place-content",
"place-items",
"place-self"
]);
// The stroke lengths a bare number writes in px, the unit it is read in.
const SVG_USER_UNIT_PROPERTIES = new Set([
"stroke-dasharray",
"stroke-dashoffset",
"stroke-width"
]);
// The displays that lay a box out by the 2009 flexbox draft, and that draft's
// prefixed properties, which such a box reads in place of their replacements.
const LEGACY_BOX_DISPLAYS = new Set([
"-webkit-box",
"-webkit-inline-box",
"-moz-box",
"-moz-inline-box"
]);
const LEGACY_BOX_SPELLINGS = new Set([
"-moz-box-align",
"-moz-box-direction",
"-moz-box-flex",
"-moz-box-ordinal-group",
"-moz-box-orient",
"-moz-box-pack",
"-webkit-box-align",
"-webkit-box-direction",
"-webkit-box-flex",
"-webkit-box-ordinal-group",
"-webkit-box-orient",
"-webkit-box-pack"
]);
// The keywords a shorthand's longhands disagree on, so a merge writing one into
// every slot would turn a declaration the engine kept into a shorthand it drops:
// `justify-items` takes `left` and `align-items` does not.
const UNSHARED_LONGHAND_KEYWORDS = new Map([
["place-content", new Set(["baseline", "first", "last", "left", "right"])],
["place-items", new Set(["left", "legacy", "right"])],
["place-self", new Set(["left", "right"])]
]);
// WHY: The shorthands written as an order-free `||` of their own longhands, each
// appearing once, in grammar order. A merge emits every value, so the only
// question is whether each parses back into the longhand it was authored on.
// prettier-ignore
// The properties whose value ends in a family list, out of the grammars: the
// longhand and the shorthands that reference it.
const FAMILY_LIST_PROPERTIES = new Set(["font", "font-family"]);
const FAMILY_LONGHANDS = new Map([
[
"border-block-end",
[
"border-block-end-width",
"border-block-end-style",
"border-block-end-color"
]
],
[
"border-block-start",
[
"border-block-start-width",
"border-block-start-style",
"border-block-start-color"
]
],
[
"border-bottom",
["border-bottom-width", "border-bottom-style", "border-bottom-color"]
],
[
"border-inline-end",
[
"border-inline-end-width",
"border-inline-end-style",
"border-inline-end-color"
]
],
[
"border-inline-start",
[
"border-inline-start-width",
"border-inline-start-style",
"border-inline-start-color"
]
],
[
"border-left",
["border-left-width", "border-left-style", "border-left-color"]
],
[
"border-right",
["border-right-width", "border-right-style", "border-right-color"]
],
["border-top", ["border-top-width", "border-top-style", "border-top-color"]],
[
"column-rule",
["column-rule-width", "column-rule-style", "column-rule-color"]
],
["flex-flow", ["flex-direction", "flex-wrap"]],
[
"list-style",
["list-style-type", "list-style-position", "list-style-image"]
],
["outline", ["outline-width", "outline-style", "outline-color"]],
[
"text-decoration",
[
"text-decoration-line",
"text-decoration-style",
"text-decoration-color",
"text-decoration-thickness"
]
],
["text-emphasis", ["text-emphasis-style", "text-emphasis-color"]],
["text-wrap", ["text-wrap-mode", "text-wrap-style"]]
]);
// The `animation` longhands whose every value is a keyword, and those keywords.
const ANIMATION_KEYWORD_SLOTS = new Map([
[
"animation-timing-function",
[
"ease",
"ease-in",
"ease-in-out",
"ease-out",
"linear",
"step-end",
"step-start"
]
],
[
"animation-direction",
["alternate", "alternate-reverse", "normal", "reverse"]
],
["animation-fill-mode", ["backwards", "both", "forwards", "none"]],
["animation-play-state", ["paused", "running"]]
]);
// The properties whose comma-separated items take a `<custom-ident>`, where a
// vendor spelling is a name the engine parses rather than one it may drop — so a
// later declaration listing an earlier one's items cannot be its fallback.
const CUSTOM_IDENT_LIST_PROPERTIES = new Set([
"animation",
"animation-name",
"animation-trigger",
"font-family",
"font-variant",
"font-variant-alternates",
"timeline-trigger-name",
"timeline-trigger-source",
"transition",
"transition-property",
"trigger-scope",
"will-change"
]);
// The shorthands whose grammar juxtaposes its longhands in a fixed order, so a
// merge writes every value by position rather than reading which slot takes it.
const ORDERED_LONGHANDS = new Map([
["flex", ["flex-grow", "flex-shrink", "flex-basis"]]
]);
const SLASH_LONGHANDS = new Map([
["container", ["container-name", "container-type"]],
[
"grid-area",
["grid-row-start", "grid-column-start", "grid-row-end", "grid-column-end"]
],
["grid-column", ["grid-column-start", "grid-column-end"]],
["grid-row", ["grid-row-start", "grid-row-end"]]
]);
// Every other spelling of a property — vendor, alternative or legacy — mapped to
// the property, so two declarations of one property are known wherever spelled.
const getPropertyAliases = memoize(
() =>
new Map([
["-khtml-box-align", "box-align"],
["-khtml-box-direction", "box-direction"],
["-khtml-box-flex", "box-flex"],
["-khtml-box-flex-group", "box-flex-group"],
["-khtml-box-lines", "box-lines"],
["-khtml-box-ordinal-group", "box-ordinal-group"],
["-khtml-box-orient", "box-orient"],
["-khtml-box-pack", "box-pack"],
["-khtml-line-break", "line-break"],
["-khtml-opacity", "opacity"],
["-khtml-user-modify", "user-modify"],
["-khtml-user-select", "user-select"],
["-moz-animation", "animation"],
["-moz-animation-delay", "animation-delay"],
["-moz-animation-direction", "animation-direction"],
["-moz-animation-duration", "animation-duration"],
["-moz-animation-fill-mode", "animation-fill-mode"],
["-moz-animation-iteration-count", "animation-iteration-count"],
["-moz-animation-name", "animation-name"],
["-moz-animation-play-state", "animation-play-state"],
["-moz-animation-timing-function", "animation-timing-function"],
["-moz-appearance", "appearance"],
["-moz-backface-visibility", "backface-visibility"],
["-moz-background-clip", "background-clip"],
["-moz-background-origin", "background-origin"],
["-moz-background-size", "background-size"],
["-moz-border-end-color", "border-inline-end-color"],
["-moz-border-end-style", "border-inline-end-style"],
["-moz-border-end-width", "border-inline-end-width"],
["-moz-border-image", "border-image"],
["-moz-border-radius", "border-radius"],
["-moz-border-radius-bottomleft", "border-bottom-left-radius"],
["-moz-border-radius-bottomright", "border-bottom-right-radius"],
["-moz-border-radius-topleft", "border-top-left-radius"],
["-moz-border-radius-topright", "border-top-right-radius"],
["-moz-border-start-color", "border-inline-start-color"],
["-moz-border-start-style", "border-inline-start-style"],
["-moz-box-align", "align-items"],
["-moz-box-direction", "flex-direction"],
["-moz-box-flex", "flex"],
["-moz-box-ordinal-group", "order"],
["-moz-box-orient", "flex-direction"],
["-moz-box-pack", "justify-content"],
["-moz-box-shadow", "box-shadow"],
["-moz-box-sizing", "box-sizing"],
["-moz-column-count", "column-count"],
["-moz-column-fill", "column-fill"],
["-moz-column-gap", "column-gap"],
["-moz-column-rule", "column-rule"],
["-moz-column-rule-color", "column-rule-color"],
["-moz-column-rule-style", "column-rule-style"],
["-moz-column-rule-width", "column-rule-width"],
["-moz-column-width", "column-width"],
["-moz-columns", "columns"],
["-moz-font-feature-settings", "font-feature-settings"],
["-moz-font-language-override", "font-language-override"],
["-moz-hyphens", "hyphens"],
["-moz-margin-end", "margin-inline-end"],
["-moz-margin-start", "margin-inline-start"],
["-moz-opacity", "opacity"],
["-moz-osx-font-smoothing", "font-smooth"],
["-moz-outline", "outline"],
["-moz-outline-color", "outline-color"],
["-moz-outline-style", "outline-style"],
["-moz-outline-width", "outline-width"],
["-moz-padding-end", "padding-inline-end"],
["-moz-padding-start", "padding-inline-start"],
["-moz-perspective", "perspective"],
["-moz-perspective-origin", "perspective-origin"],
["-moz-tab-size", "tab-size"],
["-moz-text-align-last", "text-align-last"],
["-moz-text-decoration-color", "text-decoration-color"],
["-moz-text-decoration-line", "text-decoration-line"],
["-moz-text-decoration-style", "text-decoration-style"],
["-moz-text-size-adjust", "text-size-adjust"],
["-moz-transform", "transform"],
["-moz-transform-origin", "transform-origin"],
["-moz-transform-style", "transform-style"],
["-moz-transition", "transition"],
["-moz-transition-delay", "transition-delay"],
["-moz-transition-duration", "transition-duration"],
["-moz-transition-property", "transition-property"],
["-moz-transition-timing-function", "transition-timing-function"],
["-moz-user-modify", "user-modify"],
["-moz-user-select", "user-select"],
["-ms-flex", "flex"],
["-ms-flex-align", "align-items"],
["-ms-flex-direction", "flex-direction"],
["-ms-flex-flow", "flex-flow"],
["-ms-flex-item-align", "align-self"],
["-ms-flex-line-pack", "align-content"],
["-ms-flex-negative", "flex-shrink"],
["-ms-flex-order", "order"],
["-ms-flex-pack", "justify-content"],
["-ms-flex-positive", "flex-grow"],
["-ms-flex-preferred-size", "flex-basis"],
["-ms-flex-wrap", "flex-wrap"],
["-ms-grid-columns", "grid-template-columns"],
["-ms-grid-rows", "grid-template-rows"],
["-ms-high-contrast-adjust", "forced-color-adjust"],
["-ms-hyphens", "hyphens"],
["-ms-ime-mode", "ime-mode"],
["-ms-line-break", "line-break"],
["-ms-order", "order"],
["-ms-overflow-x", "overflow-x"],
["-ms-overflow-y", "overflow-y"],
["-ms-scroll-snap-type", "scroll-snap-type"],
["-ms-text-combine-horizontal", "text-combine-upright"],
["-ms-text-overflow", "text-overflow"],
["-ms-text-size-adjust", "text-size-adjust"],
["-ms-touch-action", "touch-action"],
["-ms-transform", "transform"],
["-ms-transform-origin", "transform-origin"],
["-ms-transition", "transition"],
["-ms-transition-delay", "transition-delay"],
["-ms-transition-duration", "transition-duration"],
["-ms-transition-property", "transition-property"],
["-ms-transition-timing-function", "transition-timing-function"],
["-ms-user-select", "user-select"],
["-ms-word-break", "word-break"],
["-ms-writing-mode", "writing-mode"],
["-o-animation", "animation"],
["-o-animation-delay", "animation-delay"],
["-o-animation-direction", "animation-direction"],
["-o-animation-duration", "animation-duration"],
["-o-animation-fill-mode", "animation-fill-mode"],
["-o-animation-iteration-count", "animation-iteration-count"],
["-o-animation-name", "animation-name"],
["-o-animation-play-state", "animation-play-state"],
["-o-animation-timing-function", "animation-timing-function"],
["-o-background-size", "background-size"],
["-o-border-image", "border-image"],
["-o-object-fit", "object-fit"],
["-o-object-position", "object-position"],
["-o-tab-size", "tab-size"],
["-o-text-overflow", "text-overflow"],
["-o-transform", "transform"],
["-o-transform-origin", "transform-origin"],
["-o-transition", "transition"],
["-o-transition-delay", "transition-delay"],
["-o-transition-duration", "transition-duration"],
["-o-transition-property", "transition-property"],
["-o-transition-timing-function", "transition-timing-function"],
["-webkit-align-content", "align-content"],
["-webkit-align-items", "align-items"],
["-webkit-align-self", "align-self"],
["-webkit-alt", "alt"],
["-webkit-animation", "animation"],
["-webkit-animation-delay", "animation-delay"],
["-webkit-animation-direction", "animation-direction"],
["-webkit-animation-duration", "animation-duration"],
["-webkit-animation-fill-mode", "animation-fill-mode"],
["-webkit-animation-iteration-count", "animation-iteration-count"],
["-webkit-animation-name", "animation-name"],
["-webkit-animation-play-state", "animation-play-state"],
["-webkit-animation-timing-function", "animation-timing-function"],
["-webkit-appearance", "appearance"],
["-webkit-backdrop-filter", "backdrop-filter"],
["-webkit-backface-visibility", "backface-visibility"],
["-webkit-background-clip", "background-clip"],
["-webkit-background-origin", "background-origin"],
["-webkit-background-size", "background-size"],
["-webkit-border-bottom-left-radius", "border-bottom-left-radius"],
["-webkit-border-bottom-right-radius", "border-bottom-right-radius"],
["-webkit-border-image", "border-image"],
["-webkit-border-image-slice", "border-image-slice"],
["-webkit-border-radius", "border-radius"],
["-webkit-border-top-left-radius", "border-top-left-radius"],
["-webkit-border-top-right-radius", "border-top-right-radius"],
["-webkit-box-align", "align-items"],
["-webkit-box-decoration-break", "box-decoration-break"],
["-webkit-box-direction", "flex-direction"],
["-webkit-box-flex", "flex"],
["-webkit-box-flex-group", "box-flex-group"],
["-webkit-box-lines", "box-lines"],
["-webkit-box-ordinal-group", "order"],
["-webkit-box-orient", "flex-direction"],
["-webkit-box-pack", "justify-content"],
["-webkit-box-shadow", "box-shadow"],
["-webkit-box-sizing", "box-sizing"],
["-webkit-clip-path", "clip-path"],
["-webkit-column-break-after", "break-after"],
["-webkit-column-break-before", "break-before"],
["-webkit-column-break-inside", "break-inside"],
["-webkit-column-count", "column-count"],
["-webkit-column-fill", "column-fill"],
["-webkit-column-gap", "column-gap"],
["-webkit-column-rule", "column-rule"],
["-webkit-column-rule-color", "column-rule-color"],
["-webkit-column-rule-style", "column-rule-style"],
["-webkit-column-rule-width", "column-rule-width"],
["-webkit-column-span", "column-span"],
["-webkit-column-width", "column-width"],
["-webkit-columns", "columns"],
["-webkit-filter", "filter"],
["-webkit-flex", "flex"],
["-webkit-flex-basis", "flex-basis"],
["-webkit-flex-direction", "flex-direction"],
["-webkit-flex-flow", "flex-flow"],
["-webkit-flex-grow", "flex-grow"],
["-webkit-flex-shrink", "flex-shrink"],
["-webkit-flex-wrap", "flex-wrap"],
["-webkit-font-feature-settings", "font-feature-settings"],
["-webkit-font-kerning", "font-kerning"],
["-webkit-font-smoothing", "font-smooth"],
["-webkit-font-variant-ligatures", "font-variant-ligatures"],
["-webkit-hyphenate-character", "hyphenate-character"],
["-webkit-hyphens", "hyphens"],
["-webkit-initial-letter", "initial-letter"],
["-webkit-justify-content", "justify-content"],
["-webkit-line-break", "line-break"],
["-webkit-line-clamp", "line-clamp"],
["-webkit-logical-height", "block-size"],
["-webkit-logical-width", "inline-size"],
["-webkit-margin-after", "margin-block-end"],
["-webkit-margin-before", "margin-block-start"],
["-webkit-margin-end", "margin-inline-end"],
["-webkit-margin-start", "margin-inline-start"],
["-webkit-mask", "mask"],
["-webkit-mask-box-image", "mask-border"],
["-webkit-mask-box-image-outset", "mask-border-outset"],
["-webkit-mask-box-image-repeat", "mask-border-repeat"],
["-webkit-mask-box-image-slice", "mask-border-slice"],
["-webkit-mask-box-image-source", "mask-border-source"],
["-webkit-mask-box-image-width", "mask-border-width"],
["-webkit-mask-clip", "mask-clip"],
["-webkit-mask-composite", "mask-composite"],
["-webkit-mask-image", "mask-image"],
["-webkit-mask-origin", "mask-origin"],
["-webkit-mask-position", "mask-position"],
["-webkit-mask-repeat", "mask-repeat"],
["-webkit-mask-size", "mask-size"],
["-webkit-max-inline-size", "max-inline-size"],
["-webkit-max-logical-height", "max-block-size"],
["-webkit-max-logical-width", "max-inline-size"],
["-webkit-min-logical-height", "min-block-size"],
["-webkit-min-logical-width", "min-inline-size"],
["-webkit-order", "order"],
["-webkit-padding-end", "padding-inline-end"],
["-webkit-padding-start", "padding-inline-start"],
["-webkit-perspective", "perspective"],
["-webkit-perspective-origin", "perspective-origin"],
["-webkit-print-color-adjust", "print-color-adjust"],
["-webkit-ruby-position", "ruby-position"],
["-webkit-scroll-snap-type", "scroll-snap-type"],
["-webkit-shape-image-threshold", "shape-image-threshold"],
["-webkit-shape-margin", "shape-margin"],
["-webkit-shape-outside", "shape-outside"],
["-webkit-text-combine", "text-combine-upright"],
["-webkit-text-decoration-color", "text-decoration-color"],
["-webkit-text-decoration-line", "text-decoration-line"],
["-webkit-text-decoration-skip", "text-decoration-skip"],
["-webkit-text-decoration-style", "text-decoration-style"],
["-webkit-text-emphasis", "text-emphasis"],
["-webkit-text-emphasis-color", "text-emphasis-color"],
["-webkit-text-emphasis-position", "text-emphasis-position"],
["-webkit-text-emphasis-style", "text-emphasis-style"],
["-webkit-text-orientation", "text-orientation"],
["-webkit-text-size-adjust", "text-size-adjust"],
["-webkit-text-underline-position", "text-underline-position"],
["-webkit-transform", "transform"],
["-webkit-transform-origin", "transform-origin"],
["-webkit-transform-style", "transform-style"],
["-webkit-transition", "transition"],
["-webkit-transition-delay", "transition-delay"],
["-webkit-transition-duration", "transition-duration"],
["-webkit-transition-property", "transition-property"],
["-webkit-transition-timing-function", "transition-timing-function"],
["-webkit-user-modify", "user-modify"],
["-webkit-user-select", "user-select"],
["-webkit-writing-mode", "writing-mode"],
["color-adjust", "print-color-adjust"],
["grid-column-gap", "column-gap"],
["grid-gap", "gap"],
["grid-row-gap", "row-gap"],
["inset-area", "position-area"],
["motion", "offset"],
["motion-distance", "offset-distance"],
["motion-path", "offset-path"],
["motion-rotation", "offset-rotate"],