Skip to content

Commit

Permalink
Adding other available pseudofunctionnames+tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janlent1 committed Mar 28, 2023
1 parent 97c4037 commit 4a41029
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/css/CssParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ class CssParser extends Parser {
let lastIdentifier = undefined;
const modeStack = [];
let awaitRightParenthesis = false;
const pseudoFunctionNames = [
":matches",
":not",
":is",
":where",
":has",
":current",
":past",
":future",
"-moz-any",
"-webkit-any"
];
const isTopLevelLocal = () =>
modeData === "local" ||
(this.defaultMode === "local" && modeData === undefined);
Expand Down Expand Up @@ -564,7 +576,7 @@ class CssParser extends Parser {
modeData = "local";
const dep = new ConstDependency("", [start, end]);
module.addPresentationalDependency(dep);
} else if ([":not", ":is"].includes(name)) {
} else if (pseudoFunctionNames.includes(name)) {
awaitRightParenthesis = true;
modeStack.push(false);
} else {
Expand Down
8 changes: 8 additions & 0 deletions test/configCases/css/css-modules-in-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions test/configCases/css/css-modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
42 changes: 42 additions & 0 deletions test/configCases/css/css-modules/style.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,48 @@
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;
}
Expand Down
8 changes: 8 additions & 0 deletions test/configCases/css/css-modules/use-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ export default {
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,
Expand Down

0 comments on commit 4a41029

Please sign in to comment.