Skip to content

Commit 531652f

Browse files
style(css): hold the new comments to the two-line limit
Also drops a leftover `@returns`-only JSDoc block stacked above `collectColorFunctions`'s real one.
1 parent 9d23301 commit 531652f

4 files changed

Lines changed: 30 additions & 49 deletions

File tree

‎lib/css/data.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3900,9 +3900,8 @@ const COLOR_SPACE_MODEL = new Map([
39003900
]
39013901
]);
39023902

3903-
// The named colors an engine may not read while reading the rest, so one of them
3904-
// says nothing about what another engine takes. Every other name arrived with
3905-
// naming a color at all.
3903+
// The named colors an engine may not read while reading the rest, so one says
3904+
// nothing about what another takes. Every other name is as old as naming one.
39063905
const LATER_COLOR_NAMES = new Set(["rebeccapurple", "transparent"]);
39073906

39083907
// Every named color as its packed `0xrrggbb` value — what a color a mix or a

‎test/CssSyntax.unittest.js‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4271,10 +4271,8 @@ describe("CssSyntax minify — the value transforms' rejection paths", () => {
42714271
});
42724272

42734273
it("joins the same selector's two rules where one overrides the other", () => {
4274-
// One block holds a property once, so a property both of them set joins
4275-
// only where the later declaration is one the earlier cannot have been
4276-
// read behind — which is the same question a repeated property inside
4277-
// one block answers.
4274+
// One block holds a property once, so two blocks join only where the later
4275+
// declaration is one the earlier cannot have been read behind.
42784276
expect(minify("a{color:red}a{color:blue}")).toBe("a{color:blue}");
42794277
expect(minify("a{color:red;top:0}a{color:blue;left:0}")).toBe(
42804278
"a{top:0;color:blue;left:0}"
@@ -5794,9 +5792,8 @@ describe("CssSyntax minify — the value transforms' rejection paths", () => {
57945792

57955793
describe("a media feature's own number", () => {
57965794
it("is written the way a value's number is", () => {
5797-
// A feature is a `<length>`, a `<ratio>` or an `<integer>` and nothing
5798-
// else, so the number in one shortens like any other — where a prelude
5799-
// number elsewhere is An+B, and stripping a `+` there breaks it.
5795+
// A feature takes only a `<length>`, `<ratio>` or `<integer>`, so its number
5796+
// shortens like any other — a prelude number elsewhere is An+B.
58005797
expect(minify("@media (min-width:0480.0px){a{color:red}}")).toBe(
58015798
"@media (width>=480px){a{color:red}}"
58025799
);
@@ -5836,9 +5833,8 @@ describe("CssSyntax minify — the value transforms' rejection paths", () => {
58365833
expect(minify("@media print,all and (color){a{color:red}}")).toBe(
58375834
"@media print,(color){a{color:red}}"
58385835
);
5839-
// `all` on its own is the whole query and says everything, and `not` or
5840-
// `only` before it is not the same query at all — `only` is there to
5841-
// hide the rule from an engine reading CSS 2's grammar.
5836+
// `all` alone says everything, but `not`/`only` before it does not: `only`
5837+
// hides the rule from an engine reading CSS 2's grammar.
58425838
expect(minify("@media all{a{color:red}}")).toBe(
58435839
"@media all{a{color:red}}"
58445840
);
@@ -5917,9 +5913,8 @@ describe("CssSyntax minify — the value transforms' rejection paths", () => {
59175913
});
59185914

59195915
it.each([
5920-
// One slot takes a `<number>` and two take a `<time>`, so a layer
5921-
// naming more is one no engine reads — dropping from it would hand
5922-
// back a layer that runs.
5916+
// One slot takes a `<number>` and two a `<time>`, so a layer naming more is
5917+
// read by no engine — dropping from it would hand back one that runs.
59235918
["two counts", "a{animation:1 2}"],
59245919
["two counts, both one", "a{animation:1 1}"],
59255920
["three times", "a{animation:0s 0s 0s}"],
@@ -8777,9 +8772,8 @@ describe("CssSyntax minify — the rest of the target's abilities", () => {
87778772
"a{text-decoration:underline;text-decoration-style:dotted;" +
87788773
"text-decoration-color:red;text-decoration-thickness:2px}"
87798774
);
8780-
// The print leaves out the separator between an ident and a hash or a
8781-
// call, so the components are read back at the junctions it could have
8782-
// left bare rather than at its spaces alone.
8775+
// The print drops the separator between an ident and a hash or call, so
8776+
// components are read back at those junctions, not at its spaces alone.
87838777
expect(
87848778
minifyFor("a{text-decoration:underline 2px solid #ffffff}", ["safari 15"])
87858779
).toBe(

‎test/configCases/css/minimize-lower-unsupported-off/webpack.config.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
/** @type {import("../../../../").Configuration} */
44
module.exports = {
5-
// The same sheet and the same target as `minimize-lower-unsupported`, with
6-
// the one switch off: every spelling the target cannot read stays as it was
7-
// written, and the rest of the minifier still runs.
5+
// The sheet and target of `minimize-lower-unsupported` with the switch off:
6+
// what the target cannot read stays written, the rest of the minifier runs.
87
target: "browserslist",
98
mode: "production",
109
output: {

‎tooling/generate-css-data.js‎

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,16 +2472,12 @@ const slotSpellings = (slot) => {
24722472

24732473
/**
24742474
* Each shorthand -> the keywords a value of it may drop, and for each the other
2475-
* spellings its slot takes. A slot holding what it already defaults to says
2476-
* nothing, but only under three conditions, and every one of them is a rewrite
2477-
* that turned a declaration the engine drops into one it accepts:
2478-
* the keyword must be named by exactly one slot (`animation`'s `none` is both a
2479-
* name and a fill mode), every value that slot takes must be one the spellings
2480-
* report (`mask: url(a.svg) none` fills one slot twice and is dropped, so
2481-
* removing the `none` would revive it), and it must be a slot of its own rather
2482-
* than one reached through a `/`. What a slot takes beyond its spellings is
2483-
* carried as the value classes it names, since `#fff` is no spelling of `<color>`
2484-
* and fills the slot as surely as a keyword.
2475+
* spellings its slot takes. A keyword is droppable only where naming one slot
2476+
* (`animation`'s `none` is a name and a fill mode), where the spellings report
2477+
* every value that slot takes (`mask: url(a.svg) none` fills one slot twice and
2478+
* is dropped), and where the slot is its own rather than reached through a `/`;
2479+
* what it takes beyond them rides along as value classes, since `#fff` is no
2480+
* spelling of `<color>`.
24852481
* @param {Set<string>} colorKeywords every keyword that is a color, which is the one class a keyword itself can be in
24862482
* @returns {[string, [string, string[], string[]][]][]} the entries, sorted by property
24872483
*/
@@ -2501,9 +2497,8 @@ const collectShorthandInitialKeywords = (colorKeywords) => {
25012497
return {
25022498
named: new Set([...values.keywords].map((one) => one.toLowerCase())),
25032499
spellings: slotSpellings(slot),
2504-
// What the slot takes beyond the spellings — a length, a color, an
2505-
// image. `lib/css/syntax.js` reads a sibling's own classes against
2506-
// these, and refuses the drop for a value it cannot class at all.
2500+
// What the slot takes beyond the spellings. `syntax.js` reads a
2501+
// sibling's classes against these, and refuses one it cannot class.
25072502
classes: [...values.classes]
25082503
.filter((one) => !isSpelledClass(one))
25092504
.sort()
@@ -3186,12 +3181,8 @@ const collectLengthOnlyFunctions = () => {
31863181
};
31873182

31883183
/**
3189-
* @returns {string[]} the functions that take a color argument directly, sorted
3190-
*/
3191-
/**
3192-
* The functions that are a color, out of `<color>`'s own grammar: the calls a
3193-
* slot taking a color accepts, which is what says a value spelled as one fills
3194-
* that slot. A gradient is an `<image>` and is not among them.
3184+
* The functions that are a color, out of `<color>`'s own grammar — so a value
3185+
* spelled as one fills a color slot. A gradient is an `<image>`, not one.
31953186
* @returns {string[]} the function names, sorted
31963187
*/
31973188
const collectColorFunctions = () => {
@@ -3557,11 +3548,10 @@ const collectColorNames = (colorName) => {
35573548
};
35583549

35593550
/**
3560-
* The named colors an engine may read none of while reading the rest: the ones
3561-
* carrying a compatibility row of their own under `<named-color>`, which is
3562-
* where a name that arrived after the list did is recorded. Every other name is
3563-
* as old as naming a color at all, so one of them stands wherever another does —
3564-
* which is what lets a later declaration of one supersede an earlier.
3551+
* The named colors an engine may read none of while reading the rest — the ones
3552+
* carrying a `<named-color>` compatibility row, where a name that arrived after
3553+
* the list did is recorded. Every other name is as old as naming a color at all,
3554+
* so one stands wherever another does.
35653555
* @returns {string[]} the names, sorted
35663556
*/
35673557
const collectLaterColorNames = () => {
@@ -7122,9 +7112,8 @@ ${SUPPLEMENT.colorSpacePrimitives.map(([, source]) => source).join("\n\n")}
71227112
71237113
${colorSpaceModel.text}
71247114
7125-
// The named colors an engine may not read while reading the rest, so one of them
7126-
// says nothing about what another engine takes. Every other name arrived with
7127-
// naming a color at all.
7115+
// The named colors an engine may not read while reading the rest, so one says
7116+
// nothing about what another takes. Every other name is as old as naming one.
71287117
const LATER_COLOR_NAMES = ${setLiteral(laterColorNames)};
71297118
71307119
// Every named color as its packed \`0xrrggbb\` value — what a color a mix or a

0 commit comments

Comments
 (0)