@@ -11261,9 +11261,10 @@ const _RANGE_CONDITION_RE = /^\(([-\w]+)(>=|<=|>|<)([^()<>]+)\)$/;
1126111261
1126211262// The two shapes the range spelling prints: `(<feature><comparison><value>)` and
1126311263// `(<value><comparison><feature><comparison><value>)`. A bound holds no
11264- // comparison, so the greedy runs stop at the next one.
11264+ // comparison, so the greedy runs stop at the next one; nor opens a nested group .
1126511265const _RANGE_FEATURE_RE = /^\(([-\w]+)(>=|<=|=)([^<>=]+)\)$/;
11266- const _RANGE_INTERVAL_RE = /^\(([^<>=]+)(<=|>=)([-\w]+)(<=|>=)([^<>=]+)\)$/;
11266+ const _RANGE_INTERVAL_RE =
11267+ /^\(([^<>=(][^<>=]*)(<=|>=)([-\w]+)(<=|>=)([^<>=]+)\)$/;
1126711268
1126811269/**
1126911270 * The `min-` / `max-` condition one non-strict comparison says: `width>=X` is
@@ -11290,8 +11291,8 @@ const _minMaxCondition = (feature, comparison, value) =>
1129011291 * read Media Queries 4 range syntax.
1129111292 *
1129211293 * An interval becomes an `and` of its two bounds, which is a conjunction — so it
11293- * is parenthesized where the prelude joins with `or`, whose mixed nesting would
11294- * otherwise be a parse error . A prelude that holds an `or` is already Media
11294+ * is parenthesized where the prelude joins with `or`, or after a `not`, which
11295+ * would otherwise negate the first bound alone . A prelude that holds an `or` is already Media
1129511296 * Queries 4, so the parentheses cost that query nothing.
1129611297 * @param {string[]} parts the prelude's printed parts
1129711298 * @returns {void}
@@ -11302,10 +11303,11 @@ const _useMinMaxSpelling = (parts) => {
1130211303 let disjunction = false;
1130311304 for (let i = 0; i < parts.length; i++) {
1130411305 if (parts[i].length === 0 || parts[i] === _SEP) continue;
11305- if (equalsLowerCase (parts[i], "or") ) disjunction = true;
11306+ if (_queryKeyword (parts[i]) === "or") disjunction = true;
1130611307 filled.push(i);
1130711308 }
11308- for (const at of filled) {
11309+ for (let index = 0; index < filled.length; index++) {
11310+ const at = filled[index];
1130911311 const one = _RANGE_FEATURE_RE.exec(parts[at]);
1131011312 if (one !== null) {
1131111313 parts[at] = _minMaxCondition(one[1], one[2], one[3]);
@@ -11328,7 +11330,9 @@ const _useMinMaxSpelling = (parts) => {
1132811330 interval[5]
1132911331 );
1133011332 const pair = `${low} and ${high}`;
11331- parts[at] = disjunction ? `(${pair})` : pair;
11333+ const negated =
11334+ index > 0 && _queryKeyword(parts[filled[index - 1]]) === "not";
11335+ parts[at] = disjunction || negated ? `(${pair})` : pair;
1133211336 }
1133311337};
1133411338
0 commit comments