From ddc723d63ebfd81db6d6b9dfa105f181355d4f4a Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Fri, 16 Feb 2024 16:25:36 +1000 Subject: [PATCH] Elements: Fix block instance element styles for links applying to buttons --- src/wp-includes/block-supports/elements.php | 4 ++-- .../tests/block-supports/wpRenderElementsSupportStyles.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/block-supports/elements.php b/src/wp-includes/block-supports/elements.php index 4f3de8c5b863e..e7fa76a9ae792 100644 --- a/src/wp-includes/block-supports/elements.php +++ b/src/wp-includes/block-supports/elements.php @@ -166,8 +166,8 @@ function wp_render_elements_support_styles( $pre_render, $block ) { 'skip' => $skip_button_color_serialization, ), 'link' => array( - 'selector' => ".$class_name a", - 'hover_selector' => ".$class_name a:hover", + 'selector' => ".$class_name a:where(:not(.wp-element-button))", + 'hover_selector' => ".$class_name a:where(:not(.wp-element-button)):hover", 'skip' => $skip_link_color_serialization, ), 'heading' => array( diff --git a/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php b/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php index 0c3532a5a3841..3be0fa1e10a90 100644 --- a/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php +++ b/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php @@ -22,6 +22,7 @@ public function tear_down() { * Tests that elements block support generates appropriate styles. * * @ticket 59555 + * @ticket 60557 * * @covers ::wp_render_elements_support_styles * @@ -139,8 +140,8 @@ public function data_elements_block_support_styles() { ), ), ), - 'expected_styles' => '/^.wp-elements-[a-f0-9]{32} a' . $color_css_rules . - '.wp-elements-[a-f0-9]{32} a:hover' . $color_css_rules . '$/', + 'expected_styles' => '/^.wp-elements-[a-f0-9]{32} a:where\(:not\(.wp-element-button\)\)' . $color_css_rules . + '.wp-elements-[a-f0-9]{32} a:where\(:not\(.wp-element-button\)\):hover' . $color_css_rules . '$/', ), 'generic heading element styles are applied' => array( 'color_settings' => array( 'heading' => true ),