Skip to content
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

Update postcss-prefixwrap dependency to 1.51.0 to fix prefixing in :where selectors #64458

Merged
merged 2 commits into from
Aug 13, 2024
Merged
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
31 changes: 16 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/block-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"fast-deep-equal": "^3.1.3",
"memize": "^2.1.0",
"postcss": "^8.4.21",
"postcss-prefixwrap": "^1.41.0",
"postcss-prefixwrap": "^1.51.0",
"postcss-urlrebase": "^1.4.0",
"react-autosize-textarea": "^7.1.0",
"react-easy-crop": "^5.0.6",
Expand Down
49 changes: 49 additions & 0 deletions packages/block-editor/src/utils/test/transform-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ describe( 'transformStyles', () => {
expect( output ).toMatchSnapshot();
} );

it( `should not try to replace 'body' in the middle of a classname`, () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this unrelated test as I noticed there wasn't coverage for it.

const prefix = '.my-namespace';
const input = `.has-body-text { color: red; }`;
const output = transformStyles(
[
{
css: input,
},
],
prefix
);

expect( output ).toEqual( [ `${ prefix } ${ input }` ] );
} );

it( 'should ignore keyframes', () => {
const input = `
@keyframes edit-post__fade-in-animation {
Expand Down Expand Up @@ -210,6 +225,40 @@ describe( 'transformStyles', () => {

expect( output ).toMatchSnapshot();
} );

it( 'should not try to wrap items within `:where` selectors', () => {
const input = `:where(.wp-element-button:active, .wp-block-button__link:active) { color: blue; }`;
const prefix = '.my-namespace';
const expected = [ `${ prefix } ${ input }` ];

const output = transformStyles(
[
{
css: input,
},
],
prefix
);

expect( output ).toEqual( expected );
} );

it( 'should not try to prefix pseudo elements on `:where` selectors', () => {
const input = `:where(.wp-element-button, .wp-block-button__link)::before { color: blue; }`;
const prefix = '.my-namespace';
const expected = [ `${ prefix } ${ input }` ];

const output = transformStyles(
[
{
css: input,
},
],
prefix
);

expect( output ).toEqual( expected );
} );
} );

it( 'should not break with data urls', () => {
Expand Down
Loading