Skip to content

Commit

Permalink
test(css): add more @supports/@media cases
Browse files Browse the repository at this point in the history
  • Loading branch information
noreiller committed May 27, 2022
1 parent 7b71e81 commit a842049
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/css/CssParser.js
Expand Up @@ -384,7 +384,6 @@ class CssParser extends Parser {
if (name === "@media" || name === "@supports") {
let pos = end;
const [newPos] = eatText(input, pos, eatAtRuleNested);
pos = walkCssTokens.eatWhitespaceAndComments(input, pos);
pos = newPos;
if (pos === input.length) return pos;
if (input.charCodeAt(pos) !== CC_LEFT_CURLY) {
Expand Down
12 changes: 12 additions & 0 deletions test/configCases/css/css-modules-in-node/index.js
Expand Up @@ -24,9 +24,21 @@ it("should allow to create css modules", done => {
media: prod
? "my-app-491-w7"
: "./style.module.css-wideScreenClass",
mediaWithOperator: prod
? "my-app-491-J"
: "./style.module.css-narrowScreenClass",
supports: prod
? "my-app-491-T$"
: "./style.module.css-displayGridInSupports",
supportsWithOperator: prod
? "my-app-491-zz"
: "./style.module.css-floatRightInNegativeSupports",
mediaInSupports: prod
? "my-app-491-Kr"
: "./style.module.css-displayFlexInMediaInSupports",
supportsInMedia: prod
? "my-app-491-SQ"
: "./style.module.css-displayFlexInSupportsInMedia",
});
} catch (e) {
return done(e);
Expand Down
12 changes: 12 additions & 0 deletions test/configCases/css/css-modules/index.js
Expand Up @@ -27,9 +27,21 @@ it("should allow to create css modules", done => {
media: prod
? "my-app-491-w7"
: "./style.module.css-wideScreenClass",
mediaWithOperator: prod
? "my-app-491-J"
: "./style.module.css-narrowScreenClass",
supports: prod
? "my-app-491-T$"
: "./style.module.css-displayGridInSupports",
supportsWithOperator: prod
? "my-app-491-zz"
: "./style.module.css-floatRightInNegativeSupports",
mediaInSupports: prod
? "my-app-491-Kr"
: "./style.module.css-displayFlexInMediaInSupports",
supportsInMedia: prod
? "my-app-491-SQ"
: "./style.module.css-displayFlexInSupportsInMedia",
});
} catch (e) {
return done(e);
Expand Down
29 changes: 29 additions & 0 deletions test/configCases/css/css-modules/style.module.css
Expand Up @@ -77,8 +77,37 @@
}
}

@media screen and (max-width: 600px) {
.narrowScreenClass {
color: var(--local-color);
--local-color: purple;
}
}

@supports (display: grid) {
.displayGridInSupports {
display: grid;
}
}

@supports not (display: grid) {
.floatRightInNegativeSupports {
float: right;
}
}

@supports (display: flex) {
@media screen and (min-width: 900px) {
.displayFlexInMediaInSupports {
display: flex;
}
}
}

@media screen and (min-width: 900px) {
@supports (display: flex) {
.displayFlexInSupportsInMedia {
display: flex;
}
}
}
4 changes: 4 additions & 0 deletions test/configCases/css/css-modules/use-style.js
Expand Up @@ -12,5 +12,9 @@ export default {
animation: style.animation,
vars: `${style["local-color"]} ${style.vars} ${style["global-color"]} ${style.globalVars}`,
media: style.wideScreenClass,
mediaWithOperator: style.narrowScreenClass,
supports: style.displayGridInSupports,
supportsWithOperator: style.floatRightInNegativeSupports,
mediaInSupports: style.displayFlexInMediaInSupports,
supportsInMedia: style.displayFlexInSupportsInMedia,
};

0 comments on commit a842049

Please sign in to comment.