Make WordPress Core


Ignore:
Timestamp:
05/30/2024 01:14:15 AM (12 months 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/tests/phpunit/tests/theme/wpAddGlobalStylesForBlocks.php

    r56682 r58241  
    3838    /**
    3939     * @ticket 56915
     40     * @ticket 61165
    4041     */
    4142    public function test_third_party_blocks_inline_styles_not_register_to_global_styles() {
     
    4647
    4748        $this->assertNotContains(
    48             '.wp-block-my-third-party-block{background-color: hotpink;}',
     49            ':root :where(.wp-block-my-third-party-block){background-color: hotpink;}',
    4950            $this->get_global_styles()
    5051        );
     
    5354    /**
    5455     * @ticket 56915
     56     * @ticket 61165
    5557     */
    5658    public function test_third_party_blocks_inline_styles_get_registered_to_global_styles() {
     
    6062
    6163        $this->assertNotContains(
    62             '.wp-block-my-third-party-block{background-color: hotpink;}',
     64            ':root :where(.wp-block-my-third-party-block){background-color: hotpink;}',
    6365            $this->get_global_styles(),
    6466            'Third party block inline style should not be registered before running wp_add_global_styles_for_blocks()'
     
    6870
    6971        $this->assertContains(
    70             '.wp-block-my-third-party-block{background-color: hotpink;}',
     72            ':root :where(.wp-block-my-third-party-block){background-color: hotpink;}',
    7173            $this->get_global_styles(),
    7274            'Third party block inline style should be registered after running wp_add_global_styles_for_blocks()'
     
    7678    /**
    7779     * @ticket 56915
     80     * @ticket 61165
    7881     */
    7982    public function test_third_party_blocks_inline_styles_get_registered_to_global_styles_when_per_block() {
     
    8487
    8588        $this->assertNotContains(
    86             '.wp-block-my-third-party-block{background-color: hotpink;}',
     89            ':root :where(.wp-block-my-third-party-block){background-color: hotpink;}',
    8790            $this->get_global_styles(),
    8891            'Third party block inline style should not be registered before running wp_add_global_styles_for_blocks()'
     
    9295
    9396        $this->assertContains(
    94             '.wp-block-my-third-party-block{background-color: hotpink;}',
     97            ':root :where(.wp-block-my-third-party-block){background-color: hotpink;}',
    9598            $this->get_global_styles(),
    9699            'Third party block inline style should be registered after running wp_add_global_styles_for_blocks()'
     
    100103    /**
    101104     * @ticket 56915
     105     * @ticket 61165
    102106     */
    103107    public function test_third_party_blocks_inline_styles_get_rendered_when_per_block() {
     
    112116
    113117        $this->assertStringContainsString(
    114             '.wp-block-my-third-party-block{background-color: hotpink;}',
     118            ':root :where(.wp-block-my-third-party-block){background-color: hotpink;}',
    115119            $actual,
    116120            'Third party block inline style should render'
     
    125129    /**
    126130     * @ticket 56915
     131     * @ticket 61165
    127132     */
    128133    public function test_blocks_inline_styles_get_rendered() {
     
    134139
    135140        $this->assertStringContainsString(
    136             '.wp-block-my-third-party-block{background-color: hotpink;}',
     141            ':root :where(.wp-block-my-third-party-block){background-color: hotpink;}',
    137142            $actual,
    138143            'Third party block inline style should render'
     
    147152    /**
    148153     * @ticket 57868
     154     * @ticket 61165
    149155     */
    150156    public function test_third_party_blocks_inline_styles_for_elements_get_rendered_when_per_block() {
     
    159165
    160166        $this->assertStringContainsString(
    161             '.wp-block-my-third-party-block cite{color: white;}',
     167            ':root :where(.wp-block-my-third-party-block cite){color: white;}',
    162168            $actual
    163169        );
     
    166172    /**
    167173     * @ticket 57868
     174     * @ticket 61165
    168175     */
    169176    public function test_third_party_blocks_inline_styles_for_elements_get_rendered() {
     
    175182
    176183        $this->assertStringContainsString(
    177             '.wp-block-my-third-party-block cite{color: white;}',
     184            ':root :where(.wp-block-my-third-party-block cite){color: white;}',
    178185            $actual
    179186        );
Note: See TracChangeset for help on using the changeset viewer.