Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ exports[`transformStyles URL rewrite should rewrite relative paths 1`] = `
]
`;

exports[`transformStyles error handling should handle multiple instances of \`:where(body)\` 1`] = `
[
".my-namespace { color: pink; } .my-namespace { color: orange; }",
]
`;

exports[`transformStyles selector wrap should ignore font-face selectors 1`] = `
[
"
Expand Down
14 changes: 14 additions & 0 deletions packages/block-editor/src/utils/test/transform-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ describe( 'transformStyles', () => {
// ^^^^ In PostCSS, a tab is equal four spaces
);
} );

it( 'should handle multiple instances of `:where(body)`', () => {
const input = `:where(body) { color: pink; } :where(body) { color: orange; }`;
const output = transformStyles(
[
{
css: input,
},
],
'.my-namespace'
);

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

describe( 'selector wrap', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/block-editor/src/utils/transform-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ function transformStyle(
if ( ! wrapperSelector && ! baseURL ) {
return css;
}

const postcssFriendlyCSS = css.replace( ':where(body)', 'body' );
const postcssFriendlyCSS = css.replace( /:where\(body\)/g, 'body' );
try {
return postcss(
[
Expand Down