Make WordPress Core


Ignore:
Timestamp:
05/30/2024 01:14:15 AM (2 years ago)
Author:
isabel_brison
Message:

Editor: level global styles specificity at 0-1-0.

Adjusts the block level global styles selectors so they have a consistent specificity of 0-1-0, and adjusts base and layout global style selectors to their minimum required specificity.

Props aaronrobertshaw, isabel_brison, andrewserong, mukesh27.
Fixes #61165.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-supports/layout.php

    r58170 r58241  
    1515 *
    1616 * @since 6.3.0
     17 * @since 6.6.0 Updated specificity for compatibility with 0-1-0 global styles specificity.
    1718 * @access private
    1819 *
    … …  
    5253                        'spacingStyles' => array(
    5354                                array(
    54                                         'selector' => ' > :first-child:first-child',
     55                                        'selector' => ' > :first-child',
    5556                                        'rules'    => array(
    5657                                                'margin-block-start' => '0',
    … …  
    5859                                ),
    5960                                array(
    60                                         'selector' => ' > :last-child:last-child',
     61                                        'selector' => ' > :last-child',
    6162                                        'rules'    => array(
    6263                                                'margin-block-end' => '0',
    … …  
    117118                        'spacingStyles' => array(
    118119                                array(
    119                                         'selector' => ' > :first-child:first-child',
     120                                        'selector' => ' > :first-child',
    120121                                        'rules'    => array(
    121122                                                'margin-block-start' => '0',
    … …  
    123124                                ),
    124125                                array(
    125                                         'selector' => ' > :last-child:last-child',
     126                                        'selector' => ' > :last-child',
    126127                                        'rules'    => array(
    127128                                                'margin-block-end' => '0',
    … …  
    151152                                ),
    152153                                array(
    153                                         'selector' => ' > *',
     154                                        'selector' => ' > :is(*, div)', // :is(*, div) instead of just * increases the specificity by 001.
    154155                                        'rules'    => array(
    155156                                                'margin' => '0',
    … …  
    173174                        'baseStyles'    => array(
    174175                                array(
    175                                         'selector' => ' > *',
     176                                        'selector' => ' > :is(*, div)', // :is(*, div) instead of just * increases the specificity by 001.
    176177                                        'rules'    => array(
    177178                                                'margin' => '0',
    … …  
    223224 * @since 6.1.0 Added `$block_spacing` param, use style engine to enqueue styles.
    224225 * @since 6.3.0 Added grid layout type.
     226 * @since 6.6.0 Removed duplicated selector from layout styles.
    225227 * @access private
    226228 *
    … …  
    262264                                        ),
    263265                                        array(
    264                                                 'selector'     => "$selector$selector > * + *",
     266                                                'selector'     => "$selector > * + *",
    265267                                                'declarations' => array(
    266268                                                        'margin-block-start' => $gap_value,
    … …  
    371373                                        ),
    372374                                        array(
    373                                                 'selector'     => "$selector$selector > * + *",
     375                                                'selector'     => "$selector > * + *",
    374376                                                'declarations' => array(
    375377                                                        'margin-block-start' => $gap_value,
    … …  
    550552 * @since 6.3.0 Adds compound class to layout wrapper for global spacing styles.
    551553 * @since 6.3.0 Check for layout support via the `layout` key with fallback to `__experimentalLayout`.
     554 * @since 6.6.0 Removed duplicate container class from layout styles.
    552555 * @access private
    553556 *
    … …  
    796799
    797800                $style = wp_get_layout_style(
    798                         ".$container_class.$container_class",
     801                        ".$container_class",
    799802                        $used_layout,
    800803                        $has_block_gap_support,
Note: See TracChangeset for help on using the changeset viewer.