Skip to content

Commit

Permalink
Ensure first/last child rules take precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Aug 1, 2024
1 parent 227a064 commit c9d777e
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,26 @@ function gutenberg_get_layout_definitions() {
),
),
),
// First/last child rules need to be after `> *` rule to take
// precedence when they have the same specificity.
'spacingStyles' => array(
array(
'selector' => ' > :first-child',
'selector' => ' > *',
'rules' => array(
'margin-block-start' => '0',
'margin-block-start' => null,
'margin-block-end' => '0',
),
),
array(
'selector' => ' > :last-child',
'selector' => ' > :first-child',
'rules' => array(
'margin-block-end' => '0',
'margin-block-start' => '0',
),
),
array(
'selector' => ' > *',
'selector' => ' > :last-child',
'rules' => array(
'margin-block-start' => null,
'margin-block-end' => '0',
'margin-block-end' => '0',
),
),
),
Expand Down Expand Up @@ -110,24 +112,26 @@ function gutenberg_get_layout_definitions() {
),
),
),
// First/last child rules need to be after `> *` rule to take
// precedence when they have the same specificity.
'spacingStyles' => array(
array(
'selector' => ' > :first-child',
'selector' => ' > *',
'rules' => array(
'margin-block-start' => '0',
'margin-block-start' => null,
'margin-block-end' => '0',
),
),
array(
'selector' => ' > :last-child',
'selector' => ' > :first-child',
'rules' => array(
'margin-block-end' => '0',
'margin-block-start' => '0',
),
),
array(
'selector' => ' > *',
'selector' => ' > :last-child',
'rules' => array(
'margin-block-start' => null,
'margin-block-end' => '0',
'margin-block-end' => '0',
),
),
),
Expand Down

0 comments on commit c9d777e

Please sign in to comment.