Skip to content

Commit

Permalink
Additional CSS: Add code comments contextualising tranformStyles for …
Browse files Browse the repository at this point in the history
…clarity (WordPress#60267)

* Additional CSS: Add code comments contextualising tranformStyles for clarity

* Simplify comments, use a classname that more obviously flags that the classname will not be used in output

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>
  • Loading branch information
4 people authored and cbravobernal committed Apr 9, 2024
1 parent 57d03cc commit 0b9c01f
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ export default function AdvancedPanel( {
css: newValue,
} );
if ( cssError ) {
// Check if the new value is valid CSS, and pass a wrapping selector
// to ensure that `transformStyles` validates the CSS. Note that the
// wrapping selector here is not used in the actual output of any styles.
const [ transformed ] = transformStyles(
[ { css: newValue } ],
'.editor-styles-wrapper'
'.for-validation-only'
);
if ( transformed ) {
setCSSError( null );
Expand All @@ -43,9 +46,12 @@ export default function AdvancedPanel( {
return;
}

// Check if the new value is valid CSS, and pass a wrapping selector
// to ensure that `transformStyles` validates the CSS. Note that the
// wrapping selector here is not used in the actual output of any styles.
const [ transformed ] = transformStyles(
[ { css: event.target.value } ],
'.editor-styles-wrapper'
'.for-validation-only'
);

setCSSError(
Expand Down

0 comments on commit 0b9c01f

Please sign in to comment.