Skip to content

Commit

Permalink
fix(hiccup-css): fix media query not operator
Browse files Browse the repository at this point in the history
- wrap sub-query in parens
- update tests
  • Loading branch information
postspectacular committed Dec 22, 2023
1 parent 118a345 commit f40800b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/hiccup-css/src/conditional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const formatCond = (cond: any) => {
if (v === true) {
v = MEDIA_TYPES.has(c) ? c : `(${c})`;
} else if (v === false) {
v = "not " + (MEDIA_TYPES.has(c) ? c : `(${c})`);
v = `(not ${MEDIA_TYPES.has(c) ? c : `(${c})`})`;
} else if (v === "only") {
v += " " + c;
} else {
Expand Down
6 changes: 3 additions & 3 deletions packages/hiccup-css/test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ test("@keyframes", () => {

test("@media", () => {
expect(css(at_media({ screen: true }, []))).toBe("@media screen{}");
expect(css(at_media({ screen: false }, []))).toBe("@media not screen{}");
expect(css(at_media({ screen: false }, []))).toBe("@media (not screen){}");
expect(css(at_media({ screen: false, print: true }, []))).toBe(
"@media not screen and print{}"
"@media (not screen) and print{}"
);
expect(css(at_media({ screen: "only" }, []))).toBe("@media only screen{}");
expect(
Expand All @@ -127,7 +127,7 @@ test("@media", () => {
`@media (prefers-reduced-motion){}`
);
expect(css(at_media({ "prefers-reduced-motion": false }, []))).toBe(
`@media not (prefers-reduced-motion){}`
`@media (not (prefers-reduced-motion)){}`
);
});

Expand Down

0 comments on commit f40800b

Please sign in to comment.