Make WordPress Core

Changeset 62701


Ignore:
Timestamp:
07/13/2026 05:16:36 AM (2 months ago)
Author:
ramonopoly
Message:

Block Supports: guard test for element hover styles with a missing hover selector

This commit adds a test to cover the following behaviour: elements (such as buttons) should only render :hover element styles when they define a hover selector.

Props aaronrobertshaw, ramonopoly, westonruter, wildworks.

Follow-up to [65435].

Fixes #65538.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php

    r62520 r62701  
    2323         * @ticket 59555
    2424         * @ticket 60557
     25         * @ticket 65538
    2526         *
    2627         * @covers ::wp_render_elements_support_styles
     
    186187                                'expected_styles' => '/^.wp-elements-\d+ .wp-element-button, .wp-elements-\d+ .wp-block-button__link' . $color_css_rules . '$/',
    187188                        ),
     189                        'button hover styles are skipped without a hover selector' => array(
     190                                'color_settings'  => array( 'button' => true ),
     191                                'elements_styles' => array(
     192                                        'button' => array(
     193                                                'color'  => $color_styles,
     194                                                ':hover' => array( 'color' => $color_styles ),
     195                                        ),
     196                                ),
     197
     198                                /*
     199                                 * Only the base button rule should be emitted. The button element
     200                                 * type has no `hover_selector`, so the `:hover` object must be
     201                                 * ignored rather than triggering an undefined array key warning.
     202                                 */
     203                                'expected_styles' => '/^.wp-elements-\d+ .wp-element-button, .wp-elements-\d+ .wp-block-button__link' . $color_css_rules . '$/',
     204                        ),
    188205                        'link element styles are applied'            => array(
    189206                                'color_settings'  => array( 'link' => true ),
Note: See TracChangeset for help on using the changeset viewer.