Skip to content

Commit a00e716

Browse files
authored
[#661] @media queries should be prefixed (#662)
1 parent 320a4ec commit a00e716

File tree

7 files changed

+64
-27
lines changed

7 files changed

+64
-27
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Releases ordered so that the most recent are displayed at the top, with the curr
44
top, labeled as **🚧 In Development**. This release will be given a number once it is ready to be released. Each release
55
can contain both a **💡 Features and Improvements**, **🔧 Maintenance**, and **🐛 Bug Fixes** sections.
66

7+
## [1.56.2](https://github.com/dbtedman/postcss-prefixwrap/releases/tag/1.56.2)
8+
9+
### 🐛 Bug Fixes
10+
11+
- [#661](https://github.com/dbtedman/postcss-prefixwrap/issues/661) @media queries should be prefixed
12+
713
## [1.56.1](https://github.com/dbtedman/postcss-prefixwrap/releases/tag/1.56.1)
814

915
### 🐛 Bug Fixes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcss-prefixwrap",
3-
"version": "1.56.1",
3+
"version": "1.56.2",
44
"description": "A PostCSS plugin that is used to wrap css styles with a css selector to constrain their affect on parent elements in a page.",
55
"keywords": [
66
"css",

pnpm-lock.yaml

Lines changed: 24 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plugin/PostCSSPrefixWrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default class PostCSSPrefixWrap {
4646
)
4747
) {
4848
css.walkRules((cssRule: Rule) => {
49-
if (cssRule?.parent?.type === "root") {
49+
if (cssRule?.parent?.type !== "rule") {
5050
prefixWrapCSSRule(
5151
cssRule,
5252
this.nested,

test/MediaQuery.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as path from "path";
2+
3+
import { it } from "@jest/globals";
4+
5+
import { assertActualMatchesExpectedAfterPrefixWrap } from "./support/PrefixAssert";
6+
import { postCSSWithPlugin } from "./support/PluginBootstrap";
7+
8+
const postCSS = postCSSWithPlugin();
9+
10+
it("ensure media queries are prefixed", () => {
11+
assertActualMatchesExpectedAfterPrefixWrap(
12+
postCSS,
13+
path.join(__dirname, "fixtures", "media-query-raw.css"),
14+
path.join(__dirname, "fixtures", "media-query-expected.css"),
15+
);
16+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.my-container .something {
2+
opacity: 1;
3+
}
4+
@media screen and (min-width: 768px) {
5+
.my-container .something {
6+
opacity: 0.25;
7+
}
8+
}

test/fixtures/media-query-raw.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.something {
2+
opacity: 1;
3+
}
4+
@media screen and (min-width: 768px) {
5+
.something {
6+
opacity: 0.25;
7+
}
8+
}

0 commit comments

Comments
 (0)