Skip to content

optimize(postcss-cascade-layers): shorter output #789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/postcss-cascade-layers/dist/index.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/postcss-cascade-layers/dist/index.mjs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ function generateNot(specificity: number) {
return '';
}

let list = '';
for (let i = 0; i < specificity; i++) {
list += ':not(#\\#)'; // something short but still very uncommon
if (specificity === 1) {
return ':not(#\\#)';
}

let list = ':not(#\\#)';
for (let i = 0; i < specificity - 2; i++) {
list += ':not(_)'; // something short but still very uncommon
}
list += ':not(#\\#)';

return list;
}
4 changes: 2 additions & 2 deletions plugins/postcss-cascade-layers/test/anon-layer.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ target:not(#\#):not(#\#) {
color: yellow;
}

target:not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(#\#) {
color: green;
}

target:not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(#\#) {
color: purple;
}
4 changes: 2 additions & 2 deletions plugins/postcss-cascade-layers/test/atrules.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
}
}

#target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
#target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(_):not(#\#) {
animation: anim 1s paused;
}

@keyframes anim {
from { background-color: green; }
}

#target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::before {
#target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(_):not(#\#)::before {
content: counter(dont-care, custom-counter-style);
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/postcss-cascade-layers/test/basic.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
color: red;
}

#foo:not(#\#):not(#\#):not(#\#) #bar target::before:hover {
#foo:not(#\#):not(_):not(#\#) #bar target::before:hover {
color: green;
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(#\#) {
color: purple;
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):before {
target:not(#\#):not(_):not(_):not(_):not(_):not(#\#):before {
color: pink;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
color: red;
}

#foo:not(#\#):not(#\#):not(#\#) #bar target::before:hover {
#foo:not(#\#):not(_):not(#\#) #bar target::before:hover {
color: green;
}

#target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
#target:not(#\#):not(_):not(_):not(_):not(_):not(#\#) {
color: orange;
}

#target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
#target:not(#\#):not(_):not(_):not(_):not(_):not(#\#) {
color: yellow;
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(_):not(_):not(#\#) {
color: purple;
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):before {
target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(_):not(_):not(#\#):before {
color: pink;
}
10 changes: 5 additions & 5 deletions plugins/postcss-cascade-layers/test/container-scope.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@
}

@container (min-width: 700px) {
#foo:not(#\#):not(#\#):not(#\#) #bar target::before:hover {
#foo:not(#\#):not(_):not(#\#) #bar target::before:hover {
color: green;
}
}

#target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
#target:not(#\#):not(_):not(_):not(_):not(_):not(#\#) {
color: orange;
}

@scope (.media) to (.content) {
#target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
#target:not(#\#):not(_):not(_):not(_):not(_):not(#\#) {
color: yellow;
}
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(_):not(_):not(#\#) {
color: purple;
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):before {
target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(_):not(_):not(#\#):before {
color: pink;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ i:not(#\#) {
color: red;
}

target:not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(#\#) {
color: yellow;
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(#\#) {
color: yellow;
}

@mediA (prefers-color-scheme: dark) {
h1:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
h1:not(#\#):not(_):not(_):not(_):not(_):not(_):not(#\#) {
color: red;
background: black;
}
}

@mediA (prefers-color-scheme: dark) {
target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(#\#) {
color: lime;
}
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(_):not(#\#) {
color: yellow;
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(_):not(_):not(#\#) {
color: red;
}
14 changes: 7 additions & 7 deletions plugins/postcss-cascade-layers/test/nested-complex.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@
}

@media screen {
target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(#\#) {
layered: no;
order: 3;
}

@container (min-width: 701px) {
target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(#\#) {
layered: no;
order: 3.1;
}
}
}

@media screen {
target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(#\#) {
order: 6;
}

@media screen {
target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(#\#) {
order: 7;
}
}
Expand All @@ -50,12 +50,12 @@
@media screen {

@media screen {
target:not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(#\#) {
order: 8;
}

@media screen {
target:not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(#\#) {
order: 9;
}
}
Expand All @@ -75,7 +75,7 @@
}

@media screen {
target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(#\#) {
layered: no;
order: 5;
}
Expand Down
14 changes: 7 additions & 7 deletions plugins/postcss-cascade-layers/test/nested.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,35 @@ i:not(#\#) {
color: red;
}

target:not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(#\#) {
color: yellow;
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(#\#) {
color: yellow;
}

h1:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
h1:not(#\#):not(_):not(_):not(_):not(_):not(_):not(#\#) {
color: pink;
}

@media (prefers-color-scheme: dark) {
h2:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
h2:not(#\#):not(_):not(_):not(_):not(_):not(_):not(#\#) {
color: red;
background: black;
}
}

@media (prefers-color-scheme: dark) {
target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(#\#) {
color: lime;
}
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(_):not(#\#) {
color: yellow;
}

target:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
target:not(#\#):not(_):not(_):not(_):not(_):not(_):not(_):not(_):not(#\#) {
color: red;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
order: 1;
}

.test:not(#\#):not(#\#):not(#\#):not(#\#) {
.test:not(#\#):not(_):not(_):not(#\#) {
/* Most specific */
order: 0;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#foo:not(#\#):not(#\#):not(#\#):not(#\#) {
#foo:not(#\#):not(_):not(_):not(#\#) {
bucket: 1;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
foo:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
foo:not(#\#):not(_):not(_):not(_):not(_):not(_):not(_):not(#\#) {
bucket: 1;
}

Expand All @@ -18,18 +18,18 @@ foo {
bucket: 2;
}

foo:not(#\#):not(#\#):not(#\#):not(#\#) {
foo:not(#\#):not(_):not(_):not(#\#) {
bucket: 3;
}

#foo:not(#\#):not(#\#):not(#\#):not(#\#) {
#foo:not(#\#):not(_):not(_):not(#\#) {
bucket: 3;
}

#foo:not(#\#):not(#\#):not(#\#):not(#\#) #fooz {
#foo:not(#\#):not(_):not(_):not(#\#) #fooz {
bucket: 3;
}

#foo:not(#\#):not(#\#):not(#\#):not(#\#) #fooz #foos {
#foo:not(#\#):not(_):not(_):not(#\#) #fooz #foos {
bucket: 3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
color: revert-layer;
}/* [postcss-cascade-layers]: handling different layer orders in conditional rules is unsupported by this plugin and will cause style differences between browser versions. */
@media (min-width: 10px) {
.foo:not(#\#):not(#\#):not(#\#) {
.foo:not(#\#):not(_):not(#\#) {
color: red;
}
}
.foo:not(#\#):not(#\#):not(#\#):not(#\#) {
.foo:not(#\#):not(_):not(_):not(#\#) {
color: pink;
}
.foo:not(#\#):not(#\#):not(#\#) {
.foo:not(#\#):not(_):not(#\#) {
color: red;
}