<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[56604] trunk: Editor: add block instance element color support for buttons and headings.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/56604">56604</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/56604","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>isabel_brison</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-09-18 06:25:49 +0000 (Mon, 18 Sep 2023)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Editor: add block instance element color support for buttons and headings.

Adds support for buttons and headings to the colors and elements block supports, allowing button and heading element colors to be changed on individual blocks.

Props aaronrobertshaw.
Fixes <a href="https://core.trac.wordpress.org/ticket/59309">#59309</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesblocksupportscolorsphp">trunk/src/wp-includes/block-supports/colors.php</a></li>
<li><a href="#trunksrcwpincludesblocksupportselementsphp">trunk/src/wp-includes/block-supports/elements.php</a></li>
<li><a href="#trunksrcwpincludesstyleengineclasswpstyleenginephp">trunk/src/wp-includes/style-engine/class-wp-style-engine.php</a></li>
<li><a href="#trunktestsphpunittestsblocksupportselementsphp">trunk/tests/phpunit/tests/block-supports/elements.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesblocksupportscolorsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-supports/colors.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/colors.php   2023-09-18 00:28:24 UTC (rev 56603)
+++ trunk/src/wp-includes/block-supports/colors.php     2023-09-18 06:25:49 UTC (rev 56604)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -21,10 +21,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $has_background_colors_support = true === $color_support || ( is_array( $color_support ) && _wp_array_get( $color_support, array( 'background' ), true ) );
</span><span class="cx" style="display: block; padding: 0 10px">        $has_gradients_support         = _wp_array_get( $color_support, array( 'gradients' ), false );
</span><span class="cx" style="display: block; padding: 0 10px">        $has_link_colors_support       = _wp_array_get( $color_support, array( 'link' ), false );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        $has_button_colors_support     = _wp_array_get( $color_support, array( 'button' ), false );
+       $has_heading_colors_support    = _wp_array_get( $color_support, array( 'heading' ), false );
</ins><span class="cx" style="display: block; padding: 0 10px">         $has_color_support             = $has_text_colors_support ||
</span><span class="cx" style="display: block; padding: 0 10px">                $has_background_colors_support ||
</span><span class="cx" style="display: block; padding: 0 10px">                $has_gradients_support ||
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $has_link_colors_support;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $has_link_colors_support ||
+               $has_button_colors_support ||
+               $has_heading_colors_support;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! $block_type->attributes ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $block_type->attributes = array();
</span></span></pre></div>
<a id="trunksrcwpincludesblocksupportselementsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-supports/elements.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/elements.php 2023-09-18 00:28:24 UTC (rev 56603)
+++ trunk/src/wp-includes/block-supports/elements.php   2023-09-18 06:25:49 UTC (rev 56604)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -23,6 +23,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * Updates the block content with elements class names.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 5.8.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.4.0 Added support for button and heading element styling.
</ins><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @param string $block_content Rendered block content.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -30,34 +31,79 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @return string Filtered block content.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_render_elements_support( $block_content, $block ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( ! $block_content ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $block_content || empty( $block['attrs'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return $block_content;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $block_type                    = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
-       $skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( $skip_link_color_serialization ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $element_color_properties = array(
+               'button'  => array(
+                       'skip'  => wp_should_skip_block_supports_serialization( $block_type, 'color', 'button' ),
+                       'paths' => array(
+                               'style.elements.button.color.text',
+                               'style.elements.button.color.background',
+                               'style.elements.button.color.gradient',
+                       ),
+               ),
+               'link'    => array(
+                       'skip'  => wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' ),
+                       'paths' => array(
+                               'style.elements.link.color.text',
+                               'style.elements.link.:hover.color.text',
+                       ),
+               ),
+               'heading' => array(
+                       'skip'  => wp_should_skip_block_supports_serialization( $block_type, 'color', 'heading' ),
+                       'paths' => array(
+                               'style.elements.heading.color.text',
+                               'style.elements.heading.color.background',
+                               'style.elements.heading.color.gradient',
+                               'style.elements.h1.color.text',
+                               'style.elements.h1.color.background',
+                               'style.elements.h1.color.gradient',
+                               'style.elements.h2.color.text',
+                               'style.elements.h2.color.background',
+                               'style.elements.h2.color.gradient',
+                               'style.elements.h3.color.text',
+                               'style.elements.h3.color.background',
+                               'style.elements.h3.color.gradient',
+                               'style.elements.h4.color.text',
+                               'style.elements.h4.color.background',
+                               'style.elements.h4.color.gradient',
+                               'style.elements.h5.color.text',
+                               'style.elements.h5.color.background',
+                               'style.elements.h5.color.gradient',
+                               'style.elements.h6.color.text',
+                               'style.elements.h6.color.background',
+                               'style.elements.h6.color.gradient',
+                       ),
+               ),
+       );
+
+       $skip_all_element_color_serialization = $element_color_properties['button']['skip'] &&
+               $element_color_properties['link']['skip'] &&
+               $element_color_properties['heading']['skip'];
+
+       if ( $skip_all_element_color_serialization ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return $block_content;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $link_color = null;
-       if ( ! empty( $block['attrs'] ) ) {
-               $link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null );
-       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $element_colors_set = 0;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $hover_link_color = null;
-       if ( ! empty( $block['attrs'] ) ) {
-               $hover_link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', ':hover', 'color', 'text' ), null );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $element_color_properties as $element_config ) {
+               if ( $element_config['skip'] ) {
+                       continue;
+               }
+
+               foreach ( $element_config['paths'] as $path ) {
+                       if ( null !== _wp_array_get( $block['attrs'], explode( '.', $path ), null ) ) {
+                               $element_colors_set++;
+                       }
+               }
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        /*
-        * For now we only care about link colors.
-        * This code in the future when we have a public API
-        * should take advantage of WP_Theme_JSON::compute_style_properties
-        * and work for any element and style.
-        */
-       if ( null === $link_color && null === $hover_link_color ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $element_colors_set ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return $block_content;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -90,33 +136,84 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $block_type           = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
</span><span class="cx" style="display: block; padding: 0 10px">        $element_block_styles = isset( $block['attrs']['style']['elements'] ) ? $block['attrs']['style']['elements'] : null;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        /*
-       * For now we only care about link color.
-       */
-       $skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $element_block_styles ) {
+               return null;
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( $skip_link_color_serialization ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $skip_link_color_serialization         = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' );
+       $skip_heading_color_serialization      = wp_should_skip_block_supports_serialization( $block_type, 'color', 'heading' );
+       $skip_button_color_serialization       = wp_should_skip_block_supports_serialization( $block_type, 'color', 'button' );
+       $skips_all_element_color_serialization = $skip_link_color_serialization &&
+               $skip_heading_color_serialization &&
+               $skip_button_color_serialization;
+
+       if ( $skips_all_element_color_serialization ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return null;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $class_name        = wp_get_elements_class_name( $block );
-       $link_block_styles = isset( $element_block_styles['link'] ) ? $element_block_styles['link'] : null;
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wp_style_engine_get_styles(
-               $link_block_styles,
-               array(
-                       'selector' => ".$class_name a",
-                       'context'  => 'block-supports',
-               )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $class_name = wp_get_elements_class_name( $block );
+
+       $element_types = array(
+               'button'  => array(
+                       'selector' => ".$class_name .wp-element-button, .$class_name .wp-block-button__link",
+                       'skip'     => $skip_button_color_serialization,
+               ),
+               'link'    => array(
+                       'selector'       => ".$class_name a",
+                       'hover_selector' => ".$class_name a:hover",
+                       'skip'           => $skip_link_color_serialization,
+               ),
+               'heading' => array(
+                       'selector' => ".$class_name h1, .$class_name h2, .$class_name h3, .$class_name h4, .$class_name h5, .$class_name h6",
+                       'skip'     => $skip_heading_color_serialization,
+                       'elements' => array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ),
+               ),
</ins><span class="cx" style="display: block; padding: 0 10px">         );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( isset( $link_block_styles[':hover'] ) ) {
-               wp_style_engine_get_styles(
-                       $link_block_styles[':hover'],
-                       array(
-                               'selector' => ".$class_name a:hover",
-                               'context'  => 'block-supports',
-                       )
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $element_types as $element_type => $element_config ) {
+               if ( $element_config['skip'] ) {
+                       continue;
+               }
+
+               $element_style_object = _wp_array_get( $element_block_styles, array( $element_type ), null );
+
+               // Process primary element type styles.
+               if ( $element_style_object ) {
+                       wp_style_engine_get_styles(
+                               $element_style_object,
+                               array(
+                                       'selector' => $element_config['selector'],
+                                       'context'  => 'block-supports',
+                               )
+                       );
+
+                       if ( isset( $element_style_object[':hover'] ) ) {
+                               wp_style_engine_get_styles(
+                                       $element_style_object[':hover'],
+                                       array(
+                                               'selector' => $element_config['hover_selector'],
+                                               'context'  => 'block-supports',
+                                       )
+                               );
+                       }
+               }
+
+               // Process related elements e.g. h1-h6 for headings.
+               if ( isset( $element_config['elements'] ) ) {
+                       foreach ( $element_config['elements'] as $element ) {
+                               $element_style_object = _wp_array_get( $element_block_styles, array( $element ), null );
+
+                               if ( $element_style_object ) {
+                                       wp_style_engine_get_styles(
+                                               $element_style_object,
+                                               array(
+                                                       'selector' => ".$class_name $element",
+                                                       'context'  => 'block-supports',
+                                               )
+                                       );
+                               }
+                       }
+               }
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        return null;
</span></span></pre></div>
<a id="trunksrcwpincludesstyleengineclasswpstyleenginephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/style-engine/class-wp-style-engine.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/style-engine/class-wp-style-engine.php      2023-09-18 00:28:24 UTC (rev 56603)
+++ trunk/src/wp-includes/style-engine/class-wp-style-engine.php        2023-09-18 06:25:49 UTC (rev 56604)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -70,6 +70,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'default' => 'background-color',
</span><span class="cx" style="display: block; padding: 0 10px">                                ),
</span><span class="cx" style="display: block; padding: 0 10px">                                'path'          => array( 'color', 'background' ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'css_vars'      => array(
+                                       'color' => '--wp--preset--color--$slug',
+                               ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'classnames'    => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'has-background'             => true,
</span><span class="cx" style="display: block; padding: 0 10px">                                        'has-$slug-background-color' => 'color',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,6 +83,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'default' => 'background',
</span><span class="cx" style="display: block; padding: 0 10px">                                ),
</span><span class="cx" style="display: block; padding: 0 10px">                                'path'          => array( 'color', 'gradient' ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'css_vars'      => array(
+                                       'gradient' => '--wp--preset--gradient--$slug',
+                               ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'classnames'    => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'has-background'                => true,
</span><span class="cx" style="display: block; padding: 0 10px">                                        'has-$slug-gradient-background' => 'gradient',
</span></span></pre></div>
<a id="trunktestsphpunittestsblocksupportselementsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/block-supports/elements.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/block-supports/elements.php     2023-09-18 00:28:24 UTC (rev 56603)
+++ trunk/tests/phpunit/tests/block-supports/elements.php       2023-09-18 06:25:49 UTC (rev 56604)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -106,4 +106,68 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '<p class="wp-elements-1" id="anchor">Hello <a href="http://www.wordpress.org/">WordPress</a>!</p>'
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Test wp_render_elements_support() with a group block that has a button
+        * element color set.
+        *
+        * @ticket 59309
+        */
+       public function test_group_with_button_element_style() {
+               $result = self::make_unique_id_one(
+                       wp_render_elements_support(
+                               '<div class="wp-block-group"><div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex"><div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Button</a></div></div></div>',
+                               array(
+                                       'blockName' => 'core/group',
+                                       'attrs'     => array(
+                                               'style' => array(
+                                                       'elements' => array(
+                                                               'button' => array(
+                                                                       'color' => array(
+                                                                               'text' => 'var:preset|color|vivid-red',
+                                                                       ),
+                                                               ),
+                                                       ),
+                                               ),
+                                       ),
+                               )
+                       )
+               );
+               $this->assertSame(
+                       $result,
+                       '<div class="wp-block-group wp-elements-1"><div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex"><div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Button</a></div></div></div>'
+               );
+       }
+
+       /**
+        * Test wp_render_elements_support() with a group block that has a heading
+        * element color set.
+        *
+        * @ticket 59309
+        */
+       public function test_group_with_heading_element_style() {
+               $result = self::make_unique_id_one(
+                       wp_render_elements_support(
+                               '<div class="wp-block-group"><h2 class="wp-block-heading">Test</h2></div>',
+                               array(
+                                       'blockName' => 'core/group',
+                                       'attrs'     => array(
+                                               'style' => array(
+                                                       'elements' => array(
+                                                               'heading' => array(
+                                                                       'color' => array(
+                                                                               'text' => 'var:preset|color|vivid-red',
+                                                                       ),
+                                                               ),
+                                                       ),
+                                               ),
+                                       ),
+                               )
+                       )
+               );
+               $this->assertSame(
+                       $result,
+                       '<div class="wp-block-group wp-elements-1"><h2 class="wp-block-heading">Test</h2></div>'
+               );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>