Skip to content
Merged
Changes from 3 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
11 changes: 10 additions & 1 deletion lib/compat/wordpress-5.9/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,16 @@ private function get_block_classes( $style_nodes ) {
}
}

// Reset default browser margin on the root body element.
// We set this on the root selector **before** generating the ruleset
// from the `theme.json`. This is to ensure that if the `theme.json` declares
// `margin` in its `spacing` declaration for the `body` element then these
// user-generated values take precedence in the CSS cascade.
// See: https://github.com/WordPress/gutenberg/issues/36147.
if ( self::ROOT_BLOCK_SELECTOR === $selector ) {
$block_rules .= "body { margin: 0; }\n";
}

// 2. Generate the rules that use the general selector.
$block_rules .= self::to_ruleset( $selector, $declarations );

Expand All @@ -724,7 +734,6 @@ private function get_block_classes( $style_nodes ) {
}

if ( self::ROOT_BLOCK_SELECTOR === $selector ) {
$block_rules .= 'body { margin: 0; }';
$block_rules .= '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';
$block_rules .= '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }';
$block_rules .= '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
Expand Down