Skip to content

Commit 13488fa

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@62701 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 3f456ac commit 13488fa

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public function tear_down() {
2222
*
2323
* @ticket 59555
2424
* @ticket 60557
25+
* @ticket 65538
2526
*
2627
* @covers ::wp_render_elements_support_styles
2728
*
@@ -185,6 +186,22 @@ public function data_elements_block_support_styles() {
185186
),
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 ),
190207
'elements_styles' => array(

0 commit comments

Comments
 (0)