Skip to content

Commit 0a59be3

Browse files
alexander-akaitclaude
authored andcommitted
revert(css): drop a shadow's currentcolor for every target again
The WebKit gate rested on an MDN note no engine here could confirm.
1 parent 367a328 commit 0a59be3

5 files changed

Lines changed: 9 additions & 63 deletions

File tree

‎lib/css/syntax-parser.js‎

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,6 @@ const _setupParse = (input, lc) => {
21872187
_S._unitScale = ABSOLUTE_UNIT_SCALE;
21882188
// Back to what the module loads with, so no parse inherits a target of its own.
21892189
_S._hexAlphaAllowed = true;
2190-
_S._shadowColorOptional = false;
21912190
_S._doublePositionAllowed = true;
21922191
_S._displayTwoValuesAllowed = true;
21932192
_S._systemUiAllowed = true;
@@ -7930,7 +7929,6 @@ const grammar = (input, visitors, writer, options) => {
79307929
// No selection reads everything, which is what `_setupParse` just set.
79317930
if (_prefixBrowsers !== null) {
79327931
_S._hexAlphaAllowed = _targetSupports("colorHexAlpha");
7933-
_S._shadowColorOptional = _shadowColorDefaultsToCurrent();
79347932
_S._doublePositionAllowed = _targetSupports("gradientDoublePosition");
79357933
_S._displayTwoValuesAllowed = _targetSupports("displayTwoValues");
79367934
_S._systemUiAllowed = _targetSupports("systemUiFont");
@@ -14223,37 +14221,6 @@ const _edgeKeywordRead = (property, keyword) =>
1422314221
_valueSupportedFrom(`${property.replace(VENDOR_PREFIX, "")} ${keyword}`)
1422414222
));
1422514223

14226-
// WHY: MDN states that in Safari a shadow written without a color is transparent,
14227-
// with no version it stopped, and WebKit is not verifiable here. Pre-Chromium
14228-
// Android ran WebKit too, which the Android line left at version 37.
14229-
const _WEBKIT_BROWSERS = ["safari", "ios_saf"].map((name) =>
14230-
SUPPORT_BROWSERS.indexOf(name)
14231-
);
14232-
const _ANDROID_BROWSER = SUPPORT_BROWSERS.indexOf("android");
14233-
const _FIRST_CHROMIUM_ANDROID = /** @type {number} */ (
14234-
_encodeBrowserVersion("37")
14235-
);
14236-
14237-
/**
14238-
* Whether every target takes a shadow's absent color as `currentcolor`: none
14239-
* runs WebKit, and every one is answered for. No selection answers for none.
14240-
* @returns {boolean} true when the color may be left out
14241-
*/
14242-
const _shadowColorDefaultsToCurrent = () => {
14243-
const parsed = _prefixBrowsers;
14244-
if (parsed === null || _someBrowserUnanswered) return false;
14245-
for (const at of _WEBKIT_BROWSERS) {
14246-
if (parsed[at] !== undefined) return false;
14247-
}
14248-
const android = parsed[_ANDROID_BROWSER];
14249-
if (android !== undefined) {
14250-
for (const version of android) {
14251-
if (version < _FIRST_CHROMIUM_ANDROID) return false;
14252-
}
14253-
}
14254-
return true;
14255-
};
14256-
1425714224
/**
1425814225
* Drop each component of a family shorthand that holds its own slot's initial —
1425914226
* a slot nothing writes takes that value anyway, so writing it says nothing.
@@ -19142,8 +19109,6 @@ const _S = {
1914219109
// What the target can read, from `output.environment` — resolved once per run
1914319110
// rather than per color. Unset means it can: only browserslist reports otherwise.
1914419111
_hexAlphaAllowed: true,
19145-
// Whether a shadow's color may be left for the engine to take as `currentcolor`.
19146-
_shadowColorOptional: false,
1914719112
// Whether the color being printed is read as numbers rather than shown — a
1914819113
// gradient stop, a `color-mix()` argument, a relative color's origin — where an
1914919114
// 8-bit hex moves the color the engine computes, not only how it is spelled.

‎lib/css/syntax-printer.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,10 +2941,7 @@ const _dropShadowDefaults = (property, components) => {
29412941
const kept = [];
29422942
for (let j = 0; j < layer.length; j++) {
29432943
if (j >= last && j < end) continue;
2944-
if (
2945-
_S._shadowColorOptional &&
2946-
equalsLowerCase(layer[j], "currentcolor")
2947-
) {
2944+
if (equalsLowerCase(layer[j], "currentcolor")) {
29482945
changed = true;
29492946
continue;
29502947
}

‎test/configCases/css/minimize-corpus/__snapshots__/ConfigCacheTest.snap‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,8 +992,8 @@ Array [
992992
"/*! corpora: .foo { background-image: linear-gradient(to top right, black, white) } */.foo{background-image:linear-gradient(to top right,#000,#fff)}",
993993
"/*! corpora: .foo { mask-image: radial-gradient(circle at center, transparent 57%, currentColor 60%) } */.foo{mask-image:radial-gradient(circle,#0000 57%,currentColor 60%)}",
994994
"/*! corpora: .foo { background: conic-gradient(from 90deg at 50% 50%, black, white) } */.foo{background:conic-gradient(from 90deg,#000,#fff)}",
995-
"/*! corpora: .foo { box-shadow: 0 0 currentcolor } */.foo{box-shadow:0 0 currentcolor}",
996-
"/*! corpora: .foo { text-shadow: 1px 1px 2px currentColor, 0 0 1px red } */.foo{text-shadow:1px 1px 2px currentcolor,0 0 1px red}",
995+
"/*! corpora: .foo { box-shadow: 0 0 currentcolor } */.foo{box-shadow:0 0}",
996+
"/*! corpora: .foo { text-shadow: 1px 1px 2px currentColor, 0 0 1px red } */.foo{text-shadow:1px 1px 2px,0 0 1px red}",
997997
"/*! corpora: .foo { flex: 1 75% } */.foo{flex:75%}",
998998
"/*! corpora: .foo { padding-inline: 1rem 1rem } */.foo{padding-inline:1rem}",
999999
"/*! corpora: .foo { background: white } */.foo{background:#fff}",

‎test/configCases/css/minimize-corpus/__snapshots__/ConfigTest.snap‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,8 +992,8 @@ Array [
992992
"/*! corpora: .foo { background-image: linear-gradient(to top right, black, white) } */.foo{background-image:linear-gradient(to top right,#000,#fff)}",
993993
"/*! corpora: .foo { mask-image: radial-gradient(circle at center, transparent 57%, currentColor 60%) } */.foo{mask-image:radial-gradient(circle,#0000 57%,currentColor 60%)}",
994994
"/*! corpora: .foo { background: conic-gradient(from 90deg at 50% 50%, black, white) } */.foo{background:conic-gradient(from 90deg,#000,#fff)}",
995-
"/*! corpora: .foo { box-shadow: 0 0 currentcolor } */.foo{box-shadow:0 0 currentcolor}",
996-
"/*! corpora: .foo { text-shadow: 1px 1px 2px currentColor, 0 0 1px red } */.foo{text-shadow:1px 1px 2px currentcolor,0 0 1px red}",
995+
"/*! corpora: .foo { box-shadow: 0 0 currentcolor } */.foo{box-shadow:0 0}",
996+
"/*! corpora: .foo { text-shadow: 1px 1px 2px currentColor, 0 0 1px red } */.foo{text-shadow:1px 1px 2px,0 0 1px red}",
997997
"/*! corpora: .foo { flex: 1 75% } */.foo{flex:75%}",
998998
"/*! corpora: .foo { padding-inline: 1rem 1rem } */.foo{padding-inline:1rem}",
999999
"/*! corpora: .foo { background: white } */.foo{background:#fff}",

‎test/unitCases/CssSyntax.unittest.js‎

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4586,20 +4586,6 @@ describe("CssSyntax minify — the value transforms' rejection paths", () => {
45864586
expect(minify(css)).toBe(expected);
45874587
});
45884588

4589-
it("drops a shadow's currentcolor only where no target runs WebKit", () => {
4590-
// CSS Backgrounds 3 §7.1: an absent color is `currentcolor`.
4591-
const css = "a{text-shadow:CurrentColor 1px 1px}";
4592-
expect(minifyFor(css, ["chrome 140", "firefox 140"])).toBe(
4593-
"a{text-shadow:1px 1px}"
4594-
);
4595-
expect(minifyFor(css, ["android 140"])).toBe("a{text-shadow:1px 1px}");
4596-
for (const browsers of [["safari 26.2"], ["ios_saf 18"], ["android 4.4"]]) {
4597-
expect(minifyFor(css, browsers)).toBe(
4598-
"a{text-shadow:currentcolor 1px 1px}"
4599-
);
4600-
}
4601-
});
4602-
46034589
it.each([
46044590
["the two values differ", "a{background-repeat:repeat no-repeat}"],
46054591
["only one axis is centered", "a{background-position:center 10px}"],
@@ -6339,14 +6325,12 @@ describe("CssSyntax minify — the value transforms' rejection paths", () => {
63396325
"a{box-shadow:0px 0px 0px 1px red inset,0px 0em 0px 0px blue inset}",
63406326
"a{box-shadow:inset 0 0 0 1px red,inset 0 0 blue}"
63416327
],
6342-
// With no target, Safari may be one, and it takes an absent color as none.
6343-
[
6344-
"a{box-shadow:0 0 2px currentcolor}",
6345-
"a{box-shadow:0 0 2px currentcolor}"
6346-
],
6328+
// CSS Backgrounds 3 §7.1: an absent color is `currentcolor`.
6329+
["a{box-shadow:0 0 2px currentcolor}", "a{box-shadow:0 0 2px}"],
6330+
["a{text-shadow:CurrentColor 1px 1px}", "a{text-shadow:1px 1px}"],
63476331
[
63486332
"a{box-shadow:inset 0 0 0 0 currentcolor,0 0 red}",
6349-
"a{box-shadow:inset 0 0 currentcolor,0 0 red}"
6333+
"a{box-shadow:inset 0 0,0 0 red}"
63506334
],
63516335
// `inset` stands first, wherever the layer wrote it.
63526336
["a{box-shadow:red 1px 1px inset}", "a{box-shadow:inset red 1px 1px}"],

0 commit comments

Comments
 (0)