diff --git a/lib/block-supports/elements.php b/lib/block-supports/elements.php index 85dbd7d39797c..89275830f64b2 100644 --- a/lib/block-supports/elements.php +++ b/lib/block-supports/elements.php @@ -142,8 +142,9 @@ function gutenberg_render_elements_support_styles( $pre_render, $block ) { 'skip' => $skip_button_color_serialization, ), 'link' => array( - 'selector' => ".$class_name a", - 'hover_selector' => ".$class_name a:hover", + // :where(:not) matches theme.json selector. + '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/phpunit/block-supports/elements-test.php b/phpunit/block-supports/elements-test.php index efea11887b620..a25a5a8b3d785 100644 --- a/phpunit/block-supports/elements-test.php +++ b/phpunit/block-supports/elements-test.php @@ -273,8 +273,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 ),