Skip to content

Commit

Permalink
Transform Styles: Update selector so that styles work when custom fie…
Browse files Browse the repository at this point in the history
…lds panel is active (WordPress#62121)

* Transform Styles: Update selector so that styles work when custom fields panel is active

* Try to fix snapshot

* Chain new and old selectors to catch margin rule

Unlinked contributors: gyurmey2.

Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
  • Loading branch information
6 people authored and patil-vipul committed Jun 17, 2024
1 parent 757edf6 commit 170fe6a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports[`transformStyles URL rewrite should rewrite relative paths 1`] = `
]
`;
exports[`transformStyles error handling should handle multiple instances of \`:where(body)\` 1`] = `
exports[`transformStyles error handling should handle multiple instances of \`:root :where(body)\` 1`] = `
[
".my-namespace { color: pink; } .my-namespace { color: orange; }",
]
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/utils/test/transform-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ describe( 'transformStyles', () => {
);
} );

it( 'should handle multiple instances of `:where(body)`', () => {
const input = `:where(body) { color: pink; } :where(body) { color: orange; }`;
it( 'should handle multiple instances of `:root :where(body)`', () => {
const input = `:root :where(body) { color: pink; } :root :where(body) { color: orange; }`;
const output = transformStyles(
[
{
Expand Down
4 changes: 3 additions & 1 deletion packages/block-editor/src/utils/transform-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ function transformStyle(
if ( ! wrapperSelector && ! baseURL ) {
return css;
}
const postcssFriendlyCSS = css.replace( /:where\(body\)/g, 'body' );
const postcssFriendlyCSS = css
.replace( /:root :where\(body\)/g, 'body' )
.replace( /:where\(body\)/g, 'body' );
try {
return postcss(
[
Expand Down

0 comments on commit 170fe6a

Please sign in to comment.