diff --git a/lib/css/CssParser.js b/lib/css/CssParser.js index 12df8759aff..766ae6bc7b3 100644 --- a/lib/css/CssParser.js +++ b/lib/css/CssParser.js @@ -138,6 +138,7 @@ class CssParser extends Parser { let singleClassSelector = undefined; let lastIdentifier = undefined; const modeStack = []; + let awaitRightParenthesis = false; const isTopLevelLocal = () => modeData === "local" || (this.defaultMode === "local" && modeData === undefined); @@ -511,6 +512,9 @@ class CssParser extends Parser { rightParenthesis: (input, start, end) => { switch (mode) { case CSS_MODE_TOP_LEVEL: { + if (awaitRightParenthesis) { + awaitRightParenthesis = false; + } const newModeData = modeStack.pop(); if (newModeData !== false) { modeData = newModeData; @@ -561,6 +565,7 @@ class CssParser extends Parser { const dep = new ConstDependency("", [start, end]); module.addPresentationalDependency(dep); } else { + awaitRightParenthesis = true; modeStack.push(false); } break; @@ -597,8 +602,10 @@ class CssParser extends Parser { comma: (input, start, end) => { switch (mode) { case CSS_MODE_TOP_LEVEL: - modeData = undefined; - modeStack.length = 0; + if (!awaitRightParenthesis) { + modeData = undefined; + modeStack.length = 0; + } break; case CSS_MODE_IN_LOCAL_RULE: processDeclarationValueDone(input, start); diff --git a/test/configCases/css/css-modules-in-node/index.js b/test/configCases/css/css-modules-in-node/index.js index 5f432073ae2..ab401dff260 100644 --- a/test/configCases/css/css-modules-in-node/index.js +++ b/test/configCases/css/css-modules-in-node/index.js @@ -6,6 +6,14 @@ it("should allow to create css modules", done => { expect(x).toEqual({ global: undefined, class: prod ? "my-app-491-S" : "./style.module.css-class", + currentWmultiParams: prod ? "my-app-491-yK" : "./style.module.css-local12", + futureWmultiParams: prod ? "my-app-491-Y4" : "./style.module.css-local14", + hasWmultiParams: prod ? "my-app-491-PK" : "./style.module.css-local11", + matchesWmultiParams: prod ? "my-app-491-$Y" : "./style.module.css-local9", + mozAnyWmultiParams: prod ? "my-app-491-TT" : "./style.module.css-local15", + pastWmultiParams: prod ? "my-app-491-P_" : "./style.module.css-local13", + webkitAnyWmultiParams: prod ? "my-app-491-rT" : "./style.module.css-local16", + whereWmultiParams: prod ? "my-app-491-ie" : "./style.module.css-local10", local: prod ? "my-app-491-Zw my-app-491-yl my-app-491-J_ my-app-491-gc" : "./style.module.css-local1 ./style.module.css-local2 ./style.module.css-local3 ./style.module.css-local4", @@ -15,6 +23,12 @@ it("should allow to create css modules", done => { nested: prod ? "my-app-491-RX undefined my-app-491-X2" : "./style.module.css-nested1 undefined ./style.module.css-nested3", + notWmultiParams: prod + ? "my-app-491-Kw" + : "./style.module.css-local7", + isWmultiParams: prod + ? "my-app-491-rw" + : "./style.module.css-local8", ident: prod ? "my-app-491-yR" : "./style.module.css-ident", keyframes: prod ? "my-app-491-y3" : "./style.module.css-localkeyframes", animation: prod ? "my-app-491-oQ" : "./style.module.css-animation", diff --git a/test/configCases/css/css-modules/index.js b/test/configCases/css/css-modules/index.js index 7ec402925fb..2bd832067f4 100644 --- a/test/configCases/css/css-modules/index.js +++ b/test/configCases/css/css-modules/index.js @@ -9,6 +9,14 @@ it("should allow to create css modules", done => { expect(x).toEqual({ global: undefined, class: prod ? "my-app-491-S" : "./style.module.css-class", + currentWmultiParams: prod ? "my-app-491-yK" : "./style.module.css-local12", + futureWmultiParams: prod ? "my-app-491-Y4" : "./style.module.css-local14", + hasWmultiParams: prod ? "my-app-491-PK" : "./style.module.css-local11", + matchesWmultiParams: prod ? "my-app-491-$Y" : "./style.module.css-local9", + mozAnyWmultiParams: prod ? "my-app-491-TT" : "./style.module.css-local15", + pastWmultiParams: prod ? "my-app-491-P_" : "./style.module.css-local13", + webkitAnyWmultiParams: prod ? "my-app-491-rT" : "./style.module.css-local16", + whereWmultiParams: prod ? "my-app-491-ie" : "./style.module.css-local10", local: prod ? "my-app-491-Zw my-app-491-yl my-app-491-J_ my-app-491-gc" : "./style.module.css-local1 ./style.module.css-local2 ./style.module.css-local3 ./style.module.css-local4", @@ -18,6 +26,12 @@ it("should allow to create css modules", done => { nested: prod ? "my-app-491-RX undefined my-app-491-X2" : "./style.module.css-nested1 undefined ./style.module.css-nested3", + notWmultiParams: prod + ? "my-app-491-Kw" + : "./style.module.css-local7", + isWmultiParams: prod + ? "my-app-491-rw" + : "./style.module.css-local8", ident: prod ? "my-app-491-yR" : "./style.module.css-ident", keyframes: prod ? "my-app-491-y3" : "./style.module.css-localkeyframes", animation: prod ? "my-app-491-oQ" : "./style.module.css-animation", diff --git a/test/configCases/css/css-modules/style.module.css b/test/configCases/css/css-modules/style.module.css index 70a1cd2facf..f3fff7baee7 100644 --- a/test/configCases/css/css-modules/style.module.css +++ b/test/configCases/css/css-modules/style.module.css @@ -16,6 +16,61 @@ color: blue; } +.local7 div:not(.disabled, .mButtonDisabled, .tipOnly) { + pointer-events: initial !important; +} + +.local8 :is(div.parent1.child1.vertical-tiny, + div.parent1.child1.vertical-small, + div.otherDiv.horizontal-tiny, + div.otherDiv.horizontal-small div.description) { + max-height: 0; + margin: 0; + overflow: hidden; +} + +.local9 :matches(div.parent1.child1.vertical-tiny, + div.parent1.child1.vertical-small, + div.otherDiv.horizontal-tiny, + div.otherDiv.horizontal-small div.description) { + max-height: 0; + margin: 0; + overflow: hidden; +} + +.local10 :where(div.parent1.child1.vertical-tiny, + div.parent1.child1.vertical-small, + div.otherDiv.horizontal-tiny, + div.otherDiv.horizontal-small div.description) { + max-height: 0; + margin: 0; + overflow: hidden; +} + +.local11 div:has(.disabled, .mButtonDisabled, .tipOnly) { + pointer-events: initial !important; +} + +.local12 div:current(p, span) { + background-color: yellow; +} + +.local13 div:past(p, span) { + display: none; +} + +.local14 div:future(p, span) { + background-color: yellow; +} + +.local15 div:-moz-any(ol, ul, menu, dir) { + list-style-type: square; +} + +.local16 li:-webkit-any(:first-child, :last-child) { + background-color: aquamarine; +} + :global(:global(:local(.nested1)).nested2).nested3 { color: pink; } diff --git a/test/configCases/css/css-modules/use-style.js b/test/configCases/css/css-modules/use-style.js index 41f606240b7..28f2d0cc808 100644 --- a/test/configCases/css/css-modules/use-style.js +++ b/test/configCases/css/css-modules/use-style.js @@ -7,6 +7,16 @@ export default { local: `${local1} ${local2} ${local3} ${local4}`, local2: `${style.local5} ${style.local6}`, nested: `${style.nested1} ${style.nested2} ${style.nested3}`, + notWmultiParams: `${style.local7}`, + isWmultiParams: `${style.local8}`, + matchesWmultiParams: `${style.local9}`, + whereWmultiParams: `${style.local10}`, + hasWmultiParams: `${style.local11}`, + currentWmultiParams: `${style.local12}`, + pastWmultiParams: `${style.local13}`, + futureWmultiParams: `${style.local14}`, + mozAnyWmultiParams: `${style.local15}`, + webkitAnyWmultiParams: `${style.local16}`, ident, keyframes: style.localkeyframes, animation: style.animation,