@@ -497,17 +497,17 @@ const ONE_VALUE_PAIR_SHORTHANDS = new Set(["overflow"]);
497497// appearing once, in grammar order. A merge emits every value, so the only
498498// question is whether each parses back into the longhand it was authored on.
499499// prettier-ignore
500- const FAMILY_LONGHANDS = new Map ( [ [ "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" ] ] ] ) ;
500+ const FAMILY_LONGHANDS = new Map ( [ [ "border-bottom" , [ "border-bottom-width" , "border-bottom-style" , "border-bottom-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" ] ] ] ) ;
501501
502502// What each of those longhands accepts as a whole value: the keywords it names,
503503// and the value classes it reaches. A value acceptable to a second slot is what
504504// makes the merge ambiguous, and `FAMILY_SLOT_CLASSES` names a type the printer
505505// cannot classify as readily as one it can, so an unknown one declines.
506506// prettier-ignore
507- const FAMILY_SLOT_KEYWORDS = new Map ( [ [ "column-rule-width" , [ "medium" , "thick" , "thin" ] ] , [ "column-rule-style" , [ "dashed" , "dotted" , "double" , "groove" , "hidden" , "inset" , "none" , "outset" , "ridge" , "solid" ] ] , [ "column-rule-color" , [ ] ] , [ "flex-direction" , [ "column" , "column-reverse" , "row" , "row-reverse" ] ] , [ "flex-wrap" , [ "nowrap" , "wrap" , "wrap-reverse" ] ] , [ "list-style-type" , [ "none" ] ] , [ "list-style-position" , [ "inside" , "outside" ] ] , [ "list-style-image" , [ "none" ] ] , [ "outline-width" , [ "medium" , "thick" , "thin" ] ] , [ "outline-style" , [ "auto" , "dashed" , "dotted" , "double" , "groove" , "inset" , "none" , "outset" , "ridge" , "solid" ] ] , [ "outline-color" , [ "auto" ] ] , [ "text-decoration-line" , [ "blink" , "grammar-error" , "line-through" , "none" , "overline" , "spelling-error" , "underline" ] ] , [ "text-decoration-style" , [ "dashed" , "dotted" , "double" , "solid" , "wavy" ] ] , [ "text-decoration-color" , [ ] ] , [ "text-decoration-thickness" , [ "auto" , "from-font" ] ] , [ "text-emphasis-style" , [ "circle" , "dot" , "double-circle" , "filled" , "none" , "open" , "sesame" , "triangle" ] ] , [ "text-emphasis-color" , [ ] ] , [ "text-wrap-mode" , [ "nowrap" , "wrap" ] ] , [ "text-wrap-style" , [ "auto" , "balance" , "pretty" , "stable" ] ] ] ) ;
507+ const FAMILY_SLOT_KEYWORDS = new Map ( [ [ "border-bottom-width" , [ "medium" , "thick" , "thin" ] ] , [ "border-bottom-style" , [ "dashed" , "dotted" , "double" , "groove" , "hidden" , "inset" , "none" , "outset" , "ridge" , "solid" ] ] , [ "border-bottom-color" , [ ] ] , [ "border-left-width" , [ "medium" , "thick" , "thin" ] ] , [ "border-left-style" , [ "dashed" , "dotted" , "double" , "groove" , "hidden" , "inset" , "none" , "outset" , "ridge" , "solid" ] ] , [ "border-left-color" , [ ] ] , [ "border-right-width" , [ "medium" , "thick" , "thin" ] ] , [ "border-right-style" , [ "dashed" , "dotted" , "double" , "groove" , "hidden" , "inset" , "none" , "outset" , "ridge" , "solid" ] ] , [ "border-right-color" , [ ] ] , [ "border-top-width" , [ "medium" , "thick" , "thin" ] ] , [ "border-top-style" , [ "dashed" , "dotted" , "double" , "groove" , "hidden" , "inset" , "none" , "outset" , "ridge" , "solid" ] ] , [ "border-top-color" , [ ] ] , [ "column-rule-width" , [ "medium" , "thick" , "thin" ] ] , [ "column-rule-style" , [ "dashed" , "dotted" , "double" , "groove" , "hidden" , "inset" , "none" , "outset" , "ridge" , "solid" ] ] , [ "column-rule-color" , [ ] ] , [ "flex-direction" , [ "column" , "column-reverse" , "row" , "row-reverse" ] ] , [ "flex-wrap" , [ "nowrap" , "wrap" , "wrap-reverse" ] ] , [ "list-style-type" , [ "none" ] ] , [ "list-style-position" , [ "inside" , "outside" ] ] , [ "list-style-image" , [ "none" ] ] , [ "outline-width" , [ "medium" , "thick" , "thin" ] ] , [ "outline-style" , [ "auto" , "dashed" , "dotted" , "double" , "groove" , "inset" , "none" , "outset" , "ridge" , "solid" ] ] , [ "outline-color" , [ "auto" ] ] , [ "text-decoration-line" , [ "blink" , "grammar-error" , "line-through" , "none" , "overline" , "spelling-error" , "underline" ] ] , [ "text-decoration-style" , [ "dashed" , "dotted" , "double" , "solid" , "wavy" ] ] , [ "text-decoration-color" , [ ] ] , [ "text-decoration-thickness" , [ "auto" , "from-font" ] ] , [ "text-emphasis-style" , [ "circle" , "dot" , "double-circle" , "filled" , "none" , "open" , "sesame" , "triangle" ] ] , [ "text-emphasis-color" , [ ] ] , [ "text-wrap-mode" , [ "nowrap" , "wrap" ] ] , [ "text-wrap-style" , [ "auto" , "balance" , "pretty" , "stable" ] ] ] ) ;
508508
509509// prettier-ignore
510- const FAMILY_SLOT_CLASSES = new Map ( [ [ "column-rule-width" , [ "length" ] ] , [ "column-rule-style" , [ ] ] , [ "column-rule-color" , [ "color" ] ] , [ "flex-direction" , [ ] ] , [ "flex-wrap" , [ ] ] , [ "list-style-type" , [ "custom-ident" , "string" ] ] , [ "list-style-position" , [ ] ] , [ "list-style-image" , [ "image" ] ] , [ "outline-width" , [ "length" ] ] , [ "outline-style" , [ ] ] , [ "outline-color" , [ "color" ] ] , [ "text-decoration-line" , [ ] ] , [ "text-decoration-style" , [ ] ] , [ "text-decoration-color" , [ "color" ] ] , [ "text-decoration-thickness" , [ "length" , "percentage" ] ] , [ "text-emphasis-style" , [ "string" ] ] , [ "text-emphasis-color" , [ "color" ] ] , [ "text-wrap-mode" , [ ] ] , [ "text-wrap-style" , [ ] ] ] ) ;
510+ const FAMILY_SLOT_CLASSES = new Map ( [ [ "border-bottom-width" , [ "length" ] ] , [ "border-bottom-style" , [ ] ] , [ "border-bottom-color" , [ "color" ] ] , [ "border-left-width" , [ "length" ] ] , [ "border-left-style" , [ ] ] , [ "border-left-color" , [ "color" ] ] , [ "border-right-width" , [ "length" ] ] , [ "border-right-style" , [ ] ] , [ "border-right-color" , [ "color" ] ] , [ "border-top-width" , [ "length" ] ] , [ "border-top-style" , [ ] ] , [ "border-top-color" , [ "color" ] ] , [ "column-rule-width" , [ "length" ] ] , [ "column-rule-style" , [ ] ] , [ "column-rule-color" , [ "color" ] ] , [ "flex-direction" , [ ] ] , [ "flex-wrap" , [ ] ] , [ "list-style-type" , [ "custom-ident" , "string" ] ] , [ "list-style-position" , [ ] ] , [ "list-style-image" , [ "image" ] ] , [ "outline-width" , [ "length" ] ] , [ "outline-style" , [ ] ] , [ "outline-color" , [ "color" ] ] , [ "text-decoration-line" , [ ] ] , [ "text-decoration-style" , [ ] ] , [ "text-decoration-color" , [ "color" ] ] , [ "text-decoration-thickness" , [ "length" , "percentage" ] ] , [ "text-emphasis-style" , [ "string" ] ] , [ "text-emphasis-color" , [ "color" ] ] , [ "text-wrap-mode" , [ ] ] , [ "text-wrap-style" , [ ] ] ] ) ;
511511
512512// The identifiers that are a `<color>` on their own — named, system and the two
513513// context-dependent ones. Read off the `<color>` grammar outside any function,
@@ -892,6 +892,55 @@ const SHORTHAND_INITIAL_KEYWORDS = new Map([
892892 [ "running" , new Set ( [ "paused" , "running" ] ) ]
893893 ] )
894894 ] ,
895+ [
896+ "background" ,
897+ new Map ( [
898+ [
899+ "none" ,
900+ new Set ( [
901+ "color()" ,
902+ "color-mix()" ,
903+ "conic-gradient()" ,
904+ "cross-fade()" ,
905+ "element()" ,
906+ "hsl()" ,
907+ "hsla()" ,
908+ "hwb()" ,
909+ "image()" ,
910+ "image-set()" ,
911+ "lab()" ,
912+ "lch()" ,
913+ "light-dark()" ,
914+ "linear-gradient()" ,
915+ "none" ,
916+ "oklab()" ,
917+ "oklch()" ,
918+ "paint()" ,
919+ "radial-gradient()" ,
920+ "repeating-conic-gradient()" ,
921+ "repeating-linear-gradient()" ,
922+ "repeating-radial-gradient()" ,
923+ "rgb()" ,
924+ "rgba()" ,
925+ "src()" ,
926+ "type()" ,
927+ "url()"
928+ ] )
929+ ] ,
930+ [
931+ "repeat" ,
932+ new Set ( [
933+ "no-repeat" ,
934+ "repeat" ,
935+ "repeat-x" ,
936+ "repeat-y" ,
937+ "round" ,
938+ "space"
939+ ] )
940+ ] ,
941+ [ "scroll" , new Set ( [ "fixed" , "local" , "scroll" ] ) ]
942+ ] )
943+ ] ,
895944 [
896945 "border" ,
897946 new Map ( [
@@ -934,7 +983,41 @@ const SHORTHAND_INITIAL_KEYWORDS = new Map([
934983 ] ,
935984 [
936985 "border-image" ,
937- new Map ( [ [ "stretch" , new Set ( [ "repeat" , "round" , "space" , "stretch" ] ) ] ] )
986+ new Map ( [
987+ [
988+ "none" ,
989+ new Set ( [
990+ "color()" ,
991+ "color-mix()" ,
992+ "conic-gradient()" ,
993+ "cross-fade()" ,
994+ "element()" ,
995+ "hsl()" ,
996+ "hsla()" ,
997+ "hwb()" ,
998+ "image()" ,
999+ "image-set()" ,
1000+ "lab()" ,
1001+ "lch()" ,
1002+ "light-dark()" ,
1003+ "linear-gradient()" ,
1004+ "none" ,
1005+ "oklab()" ,
1006+ "oklch()" ,
1007+ "paint()" ,
1008+ "radial-gradient()" ,
1009+ "repeating-conic-gradient()" ,
1010+ "repeating-linear-gradient()" ,
1011+ "repeating-radial-gradient()" ,
1012+ "rgb()" ,
1013+ "rgba()" ,
1014+ "src()" ,
1015+ "type()" ,
1016+ "url()"
1017+ ] )
1018+ ] ,
1019+ [ "stretch" , new Set ( [ "repeat" , "round" , "space" , "stretch" ] ) ]
1020+ ] )
9381021 ] ,
9391022 [
9401023 "border-left" ,
@@ -1029,6 +1112,38 @@ const SHORTHAND_INITIAL_KEYWORDS = new Map([
10291112 new Map ( [
10301113 [ "add" , new Set ( [ "add" , "exclude" , "intersect" , "subtract" ] ) ] ,
10311114 [ "match-source" , new Set ( [ "alpha" , "luminance" , "match-source" ] ) ] ,
1115+ [
1116+ "none" ,
1117+ new Set ( [
1118+ "color()" ,
1119+ "color-mix()" ,
1120+ "conic-gradient()" ,
1121+ "cross-fade()" ,
1122+ "element()" ,
1123+ "hsl()" ,
1124+ "hsla()" ,
1125+ "hwb()" ,
1126+ "image()" ,
1127+ "image-set()" ,
1128+ "lab()" ,
1129+ "lch()" ,
1130+ "light-dark()" ,
1131+ "linear-gradient()" ,
1132+ "none" ,
1133+ "oklab()" ,
1134+ "oklch()" ,
1135+ "paint()" ,
1136+ "radial-gradient()" ,
1137+ "repeating-conic-gradient()" ,
1138+ "repeating-linear-gradient()" ,
1139+ "repeating-radial-gradient()" ,
1140+ "rgb()" ,
1141+ "rgba()" ,
1142+ "src()" ,
1143+ "type()" ,
1144+ "url()"
1145+ ] )
1146+ ] ,
10321147 [
10331148 "repeat" ,
10341149 new Set ( [
@@ -1046,6 +1161,38 @@ const SHORTHAND_INITIAL_KEYWORDS = new Map([
10461161 "mask-border" ,
10471162 new Map ( [
10481163 [ "alpha" , new Set ( [ "alpha" , "luminance" ] ) ] ,
1164+ [
1165+ "none" ,
1166+ new Set ( [
1167+ "color()" ,
1168+ "color-mix()" ,
1169+ "conic-gradient()" ,
1170+ "cross-fade()" ,
1171+ "element()" ,
1172+ "hsl()" ,
1173+ "hsla()" ,
1174+ "hwb()" ,
1175+ "image()" ,
1176+ "image-set()" ,
1177+ "lab()" ,
1178+ "lch()" ,
1179+ "light-dark()" ,
1180+ "linear-gradient()" ,
1181+ "none" ,
1182+ "oklab()" ,
1183+ "oklch()" ,
1184+ "paint()" ,
1185+ "radial-gradient()" ,
1186+ "repeating-conic-gradient()" ,
1187+ "repeating-linear-gradient()" ,
1188+ "repeating-radial-gradient()" ,
1189+ "rgb()" ,
1190+ "rgba()" ,
1191+ "src()" ,
1192+ "type()" ,
1193+ "url()"
1194+ ] )
1195+ ] ,
10491196 [ "stretch" , new Set ( [ "repeat" , "round" , "space" , "stretch" ] ) ]
10501197 ] )
10511198 ] ,
@@ -1156,6 +1303,17 @@ const GENERIC_FONT_FAMILIES = new Set([
11561303 "ui-serif"
11571304] ) ;
11581305
1306+ // Each gradient function -> the positions its last color stop already means, so
1307+ // writing one of them there says nothing (CSS Images 3 §3.4.3).
1308+ const GRADIENT_LAST_POSITIONS = new Map ( [
1309+ [ "conic-gradient" , new Set ( [ "100%" , "360deg" , "1turn" ] ) ] ,
1310+ [ "linear-gradient" , new Set ( [ "100%" ] ) ] ,
1311+ [ "radial-gradient" , new Set ( [ "100%" ] ) ] ,
1312+ [ "repeating-conic-gradient" , new Set ( [ "100%" , "360deg" , "1turn" ] ) ] ,
1313+ [ "repeating-linear-gradient" , new Set ( [ "100%" ] ) ] ,
1314+ [ "repeating-radial-gradient" , new Set ( [ "100%" ] ) ]
1315+ ] ) ;
1316+
11591317// The properties whose value is a position, where each edge keyword names the
11601318// percentage that axis resolves to.
11611319const POSITION_PROPERTIES = new Set ( [
@@ -1839,6 +1997,18 @@ const DROPPABLE_WHEN_EMPTY_AT_RULES = new Set([
18391997 "container"
18401998] ) ;
18411999
2000+ // At-rules whose block holds rules and whose prelude states a condition, so two
2001+ // adjacent blocks with the same prelude are the one block they resolve to.
2002+ const MERGEABLE_AT_RULES = new Set ( [
2003+ "container" ,
2004+ "document" ,
2005+ "layer" ,
2006+ "media" ,
2007+ "scope" ,
2008+ "starting-style" ,
2009+ "supports"
2010+ ] ) ;
2011+
18422012// The math functions whose result steps with their arguments, so a value inside
18432013// one keeps the unit and the digits it was written with.
18442014const STEPPED_FUNCTIONS = new Set ( [ "mod" , "rem" , "round" ] ) ;
@@ -2075,6 +2245,14 @@ const INTEGER_PROPERTIES = new Set([
20752245 "z-index"
20762246] ) ;
20772247
2248+ // The properties whose value is one `<number> | <percentage>`, where the
2249+ // percentage is the number hundredfold and the two compute to the same thing.
2250+ const ALPHA_VALUE_PROPERTIES = new Set ( [ "opacity" , "shape-image-threshold" ] ) ;
2251+
2252+ // The properties taking a `<ratio>`, whose second number of `1` is the one an
2253+ // omitted denominator means.
2254+ const RATIO_PROPERTIES = new Set ( [ "aspect-ratio" ] ) ;
2255+
20782256// The keywords of every property a `css/module` reads a scoped name out of,
20792257// each mapped to how many times it may be spelled before the next one is the
20802258// name (`Infinity` — never the name). Derived from each property's grammar.
@@ -2862,6 +3040,7 @@ const RGB_TO_NAME = new Map([
28623040] ) ;
28633041
28643042module . exports . ABSOLUTE_UNIT_SCALE = ABSOLUTE_UNIT_SCALE ;
3043+ module . exports . ALPHA_VALUE_PROPERTIES = ALPHA_VALUE_PROPERTIES ;
28653044module . exports . ANGLE_UNITS = ANGLE_UNITS ;
28663045module . exports . ARC_COSINE_DEGREES = ARC_COSINE_DEGREES ;
28673046module . exports . ARC_SINE_DEGREES = ARC_SINE_DEGREES ;
@@ -2891,6 +3070,7 @@ module.exports.FLEX_KEYWORDS = FLEX_KEYWORDS;
28913070module . exports . FONT_STRETCH_PERCENTAGES = FONT_STRETCH_PERCENTAGES ;
28923071module . exports . FONT_WEIGHT_NUMBERS = FONT_WEIGHT_NUMBERS ;
28933072module . exports . GENERIC_FONT_FAMILIES = GENERIC_FONT_FAMILIES ;
3073+ module . exports . GRADIENT_LAST_POSITIONS = GRADIENT_LAST_POSITIONS ;
28943074module . exports . INITIAL_VALUE_KEYWORDS = INITIAL_VALUE_KEYWORDS ;
28953075module . exports . INTEGER_PROPERTIES = INTEGER_PROPERTIES ;
28963076module . exports . LEGACY_PSEUDO_ELEMENTS = LEGACY_PSEUDO_ELEMENTS ;
@@ -2900,6 +3080,7 @@ module.exports.MATH_FUNCTION_ARITY = MATH_FUNCTION_ARITY;
29003080module . exports . MATH_FUNCTION_FOLD = MATH_FUNCTION_FOLD ;
29013081module . exports . MATH_FUNCTION_KEYWORDS = MATH_FUNCTION_KEYWORDS ;
29023082module . exports . MATH_FUNCTION_SUM_ARGUMENTS = MATH_FUNCTION_SUM_ARGUMENTS ;
3083+ module . exports . MERGEABLE_AT_RULES = MERGEABLE_AT_RULES ;
29033084module . exports . NEGATIVE_ACCEPTING_PROPERTIES = NEGATIVE_ACCEPTING_PROPERTIES ;
29043085module . exports . NTH_PSEUDO_FUNCTIONS = NTH_PSEUDO_FUNCTIONS ;
29053086module . exports . ONE_VALUE_PAIR_SHORTHANDS = ONE_VALUE_PAIR_SHORTHANDS ;
@@ -2908,6 +3089,7 @@ module.exports.POSITION_PROPERTIES = POSITION_PROPERTIES;
29083089module . exports . POSITION_X_KEYWORDS = POSITION_X_KEYWORDS ;
29093090module . exports . POSITION_Y_KEYWORDS = POSITION_Y_KEYWORDS ;
29103091module . exports . QUARTER_TURN_ANGLE = QUARTER_TURN_ANGLE ;
3092+ module . exports . RATIO_PROPERTIES = RATIO_PROPERTIES ;
29113093module . exports . REPEAT_STYLE_KEYWORDS = REPEAT_STYLE_KEYWORDS ;
29123094module . exports . REPEAT_STYLE_PROPERTIES = REPEAT_STYLE_PROPERTIES ;
29133095module . exports . RGB_TO_NAME = RGB_TO_NAME ;
0 commit comments