@@ -4368,6 +4368,7 @@ const _walkValue = (node, parent, index, writer) => {
43684368 let enteredMath = false;
43694369 let enteredStepped = false;
43704370 let enteredSupports = false;
4371+ let previousMedia = false;
43714372 if (!skip && (ty === T_FUNCTION || ty === T_SIMPLE_BLOCK)) {
43724373 const i0 = _nodeIndex(node);
43734374 const vs = _listStarts[i0];
@@ -4407,6 +4408,7 @@ const _walkValue = (node, parent, index, writer) => {
44074408 _isImportSupports(i0, /** @type {Node} */ (parent))
44084409 ) {
44094410 enteredSupports = true;
4411+ previousMedia = _S._inMediaConditionPrelude;
44104412 _S._inSupportsPrelude = true;
44114413 // Its `(…)` tests a declaration, which no media feature spelling reaches.
44124414 _S._inMediaConditionPrelude = false;
@@ -4421,7 +4423,7 @@ const _walkValue = (node, parent, index, writer) => {
44214423 if (enteredStepped) _S._steppedFunctionDepth--;
44224424 if (enteredSupports) {
44234425 _S._inSupportsPrelude = false;
4424- _S._inMediaConditionPrelude = true ;
4426+ _S._inMediaConditionPrelude = previousMedia ;
44254427 }
44264428};
44274429
@@ -10668,43 +10670,6 @@ const _writeCustomMedia = (parts) => {
1066810670 }
1066910671};
1067010672
10671- // WHY: CSS Conditional 3 as first published asked for whitespace on both sides
10672- // of a `@supports` `and` / `or` (`S+ AND S+`), and engines built on it read
10673- // `(a)and (b)` as invalid. So where a dropped comment was all that parted a `)`
10674- // from one, a space is written back; the one after is `_join`'s already.
10675- /**
10676- * @param {string[]} parts the condition's printed parts, one per child from `offset`
10677- * @param {Node} node the node whose children they are
10678- * @param {number} offset the index of its first child's part
10679- * @returns {void}
10680- */
10681- const _spaceConditionKeywords = (parts, node, offset) => {
10682- const i0 = _nodeIndex(node);
10683- const first = _listStarts[i0];
10684- const count = _listLens[i0];
10685- // The child before, or -1 once whitespace has parted it from the next.
10686- let previous = -1;
10687- for (let k = 0; k < count; k++) {
10688- const child = _flat[first + k];
10689- if (_types[child] === T_WHITESPACE) {
10690- previous = -1;
10691- continue;
10692- }
10693- const part = parts[offset + k];
10694- if (
10695- previous !== -1 &&
10696- _ends[_flat[first + previous]] !== _starts[child] &&
10697- (equalsLowerCase(part, "and") || equalsLowerCase(part, "or"))
10698- ) {
10699- const before = parts[offset + previous];
10700- if (before.charCodeAt(before.length - 1) === CC_RIGHT_PARENTHESIS) {
10701- parts[offset + k] = ` ${part}`;
10702- }
10703- }
10704- previous = k;
10705- }
10706- };
10707-
1070810673/**
1070910674 * Minify a media or container query's printed parts, in place, after its first
1071010675 * part — the rule's name, which none of the passes read.
@@ -14091,14 +14056,12 @@ const _rulePrelude = (path, writer, minify, outParts) => {
1409114056 const media = name === "media";
1409214057 const container = name === "container";
1409314058 // Every prelude that is a chain of conditions, whichever rule states it.
14094- const supports = equalsLowerCase(name, "supports");
1409514059 if (
1409614060 _S._transforms.shortenMediaQueries &&
14097- (media || container || supports)
14061+ (media || container || equalsLowerCase(name, " supports") )
1409814062 ) {
1409914063 _dropRepeatedConditions(parts);
1410014064 }
14101- if (supports) _spaceConditionKeywords(parts, path.node, 1);
1410214065 if (media || container) {
1410314066 _minifyMediaQueryParts(parts, media);
1410414067 } else if (name === "import") {
@@ -15795,7 +15758,6 @@ module.exports._NO_RULE_SPANS = _NO_RULE_SPANS;
1579515758module.exports._NUMERIC_RE = _NUMERIC_RE;
1579615759module.exports._S = _S;
1579715760module.exports._SEP = _SEP;
15798- module.exports._spaceConditionKeywords = _spaceConditionKeywords;
1579915761module.exports._TRIM_COMBINATORS = _TRIM_COMBINATORS;
1580015762module.exports._TRIM_CONDITIONS = _TRIM_CONDITIONS;
1580115763module.exports._TRIM_MATH = _TRIM_MATH;
0 commit comments