Skip to content

Commit

Permalink
Add specs for merging media queries that contain "all and"
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Dec 7, 2018
1 parent 3350d93 commit 3dae126
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/scss/media/nesting/merged/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
@media screen {
a {b: c}
@media (color) {x {y: z}}

// The "all and" prefix shouldn't change the semantics.
@media all and (color) {x {y: z}}
}

// Features always go to the end of a query, even if they're at an outer nesting
Expand All @@ -11,17 +14,28 @@
a {b: c}
@media screen {x {y: z}}
}
@media all and (color) {
a {b: c}
@media screen {x {y: z}}
}

// Different features can be intersected.
@media (max-width: 300px) {
a {b: c}
@media (min-width: 200px) {x {y: z}}
@media all and (min-width: 200px) {q {r: s}}
}
@media all and (max-width: 300px) {
a {b: c}
@media (min-width: 200px) {x {y: z}}
@media all and (min-width: 200px) {q {r: s}}
}

// Unlike `not`, the `only` keyword is preserved through intersection.
@media only screen {
a {b: c}
@media (color) {x {y: z}}
@media all and (color) {q {r: s}}
}

// The intersection of `not screen` and `print` is just `print`.
Expand Down
42 changes: 42 additions & 0 deletions spec/scss/media/nesting/merged/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
y: z;
}
}
@media screen and (color) {
x {
y: z;
}
}

@media (color) {
a {
Expand All @@ -20,6 +25,17 @@
}
}

@media all and (color) {
a {
b: c;
}
}
@media screen and (color) {
x {
y: z;
}
}

@media (max-width: 300px) {
a {
b: c;
Expand All @@ -30,6 +46,27 @@
y: z;
}
}
@media (max-width: 300px) and (min-width: 200px) {
q {
r: s;
}
}

@media all and (max-width: 300px) {
a {
b: c;
}
}
@media (max-width: 300px) and (min-width: 200px) {
x {
y: z;
}
}
@media all and (max-width: 300px) and (min-width: 200px) {
q {
r: s;
}
}

@media only screen {
a {
Expand All @@ -41,6 +78,11 @@
y: z;
}
}
@media only screen and (color) {
q {
r: s;
}
}

@media not screen {
a {
Expand Down
18 changes: 18 additions & 0 deletions spec/scss/media/nesting/retained/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@
@media not screen {
a {b: c}
@media (color) {x {y: z}}

// The "all and" prefix shouldn't change the semantics.
@media all and (color) {q {r: s}}
}
@media (color) {
a {b: c}
@media not screen {x {y: z}}
}
@media all and (color) {
a {b: c}
@media not screen {x {y: z}}
}

// The unification of these would be `screen and not (color)`, which isn't yet
// supported.
@media screen {
a {b: c}
@media not all and (color) {x {y: z}}
}
@media not all and (color) {
a {b: c}
@media screen {x {y: z}}
}

// `not screen and (color)` means `not (screen and (color))`, so it could still
// overlap with just `screen` in the case of a screen media without color.
Expand Down
38 changes: 38 additions & 0 deletions spec/scss/media/nesting/retained/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
y: z;
}
}
@media all and (color) {
q {
r: s;
}
}
}

@media (color) {
Expand All @@ -20,6 +25,39 @@
}
}

@media all and (color) {
a {
b: c;
}
@media not screen {
x {
y: z;
}
}
}

@media screen {
a {
b: c;
}
@media not all and (color) {
x {
y: z;
}
}
}

@media not all and (color) {
a {
b: c;
}
@media screen {
x {
y: z;
}
}
}

@media not screen and (color) {
a {
b: c;
Expand Down

0 comments on commit 3dae126

Please sign in to comment.