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
  • Loading branch information
andrewserong committed Mar 28, 2024
1 parent 99b8ea6 commit c376976
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default function AdvancedPanel( {
css: newValue,
} );
if ( cssError ) {
// Pass a wrapping selector to transformStyles to ensure that the CSS
// tested resembles actual CSS rules. This is necessary because the additional CSS
// field supports CSS rules that are not wrapped in a selector.
// Note: The wrapping selector here is not used in the actual output of any styles.
const [ transformed ] = transformStyles(
[ { css: newValue } ],
'.editor-styles-wrapper'
Expand All @@ -43,6 +47,10 @@ export default function AdvancedPanel( {
return;
}

// Pass a wrapping selector to transformStyles to ensure that the CSS
// tested resembles actual CSS rules. This is necessary because the additional CSS
// field supports CSS rules that are not wrapped in a selector.
// Note: The wrapping selector here is not used in the actual output of any styles.
const [ transformed ] = transformStyles(
[ { css: event.target.value } ],
'.editor-styles-wrapper'
Expand Down

0 comments on commit c376976

Please sign in to comment.