<!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>[58074] trunk: Editor: Merge element style and classname generation to single filter.</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/58074">58074</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/58074","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>2024-05-02 06:59:30 +0000 (Thu, 02 May 2024)</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: Merge element style and classname generation to single filter.

Fixes element classnames not being output when block attributes are filtered with `render_block_data`.

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

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesblocksupportselementsphp">trunk/src/wp-includes/block-supports/elements.php</a></li>
<li><a href="#trunktestsphpunittestsblocksupportswpRenderElementsSupportphp">trunk/tests/phpunit/tests/block-supports/wpRenderElementsSupport.php</a></li>
<li><a href="#trunktestsphpunittestsblocksupportswpRenderElementsSupportStylesphp">trunk/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<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 2024-05-01 23:59:03 UTC (rev 58073)
+++ trunk/src/wp-includes/block-supports/elements.php   2024-05-02 06:59:30 UTC (rev 58074)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -22,6 +22,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @deprecated 6.6.0 Generation of element class name is handled via `render_block_data` filter.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px">  * @since 5.8.0
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 6.4.0 Added support for button and heading element styling.
</span><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,18 +33,28 @@
</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 || ! isset( $block['attrs']['style']['elements'] ) ) {
-               return $block_content;
-       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ _deprecated_function( __FUNCTION__, '6.6.0', 'wp_render_elements_class_name' );
+       return $block_content;
+}
</ins><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'] );
-       if ( ! $block_type ) {
-               return $block_content;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Determines whether an elements class name should be added to the block.
+ *
+ * @since 6.6.0
+ * @access private
+ *
+ * @param  array $block   Block object.
+ * @param  array $options Per element type options e.g. whether to skip serialization.
+ * @return boolean Whether the block needs an elements class name.
+ */
+function wp_should_add_elements_class_name( $block, $options ) {
+       if ( ! isset( $block['attrs']['style']['elements'] ) ) {
+               return false;
</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">        $element_color_properties = array(
</span><span class="cx" style="display: block; padding: 0 10px">                'button'  => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'skip'  => wp_should_skip_block_supports_serialization( $block_type, 'color', 'button' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'skip'  => isset( $options['button']['skip'] ) ? $options['button']['skip'] : false,
</ins><span class="cx" style="display: block; padding: 0 10px">                         'paths' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                array( 'button', 'color', 'text' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                array( 'button', 'color', 'background' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,7 +62,7 @@
</span><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">                'link'    => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'skip'  => wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'skip'  => isset( $options['link']['skip'] ) ? $options['link']['skip'] : false,
</ins><span class="cx" style="display: block; padding: 0 10px">                         'paths' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                array( 'link', 'color', 'text' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                array( 'link', ':hover', 'color', 'text' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -57,7 +69,7 @@
</span><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">                'heading' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'skip'  => wp_should_skip_block_supports_serialization( $block_type, 'color', 'heading' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'skip'  => isset( $options['heading']['skip'] ) ? $options['heading']['skip'] : false,
</ins><span class="cx" style="display: block; padding: 0 10px">                         'paths' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                array( 'heading', 'color', 'text' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                array( 'heading', 'color', 'background' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -84,14 +96,6 @@
</span><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"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $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 ) {
-               return $block_content;
-       }
-
</del><span class="cx" style="display: block; padding: 0 10px">         $elements_style_attributes = $block['attrs']['style']['elements'];
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        foreach ( $element_color_properties as $element_config ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -101,31 +105,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                foreach ( $element_config['paths'] as $path ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( null !== _wp_array_get( $elements_style_attributes, $path, null ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                /*
-                                * It only takes a single custom attribute to require that the custom
-                                * class name be added to the block, so once one is found there's no
-                                * need to continue looking for others.
-                                *
-                                * As is done with the layout hook, this code assumes that the block
-                                * contains a single wrapper and that it's the first element in the
-                                * rendered output. That first element, if it exists, gets the class.
-                                */
-                               $tags = new WP_HTML_Tag_Processor( $block_content );
-                               if ( $tags->next_tag() ) {
-                                       $tags->add_class( wp_get_elements_class_name( $block ) );
-                               }
-
-                               return $tags->get_updated_html();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         return true;
</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">        }
</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 no custom attributes were found then there's nothing to modify.
-       return $block_content;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return false;
</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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Renders the elements stylesheet.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Render the elements stylesheet and adds elements class name to block as required.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * In the case of nested blocks we want the parent element styles to be rendered before their descendants.
</span><span class="cx" style="display: block; padding: 0 10px">  * This solves the issue of an element (e.g.: link color) being styled in both the parent and a descendant:
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -133,18 +122,36 @@
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 6.0.0
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 6.1.0 Implemented the style engine to generate CSS and classnames.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.6.0 Element block support class and styles are generated via the `render_block_data` filter instead of `pre_render_block`.
</ins><span class="cx" style="display: block; padding: 0 10px">  * @access private
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string|null $pre_render The pre-rendered content. Default null.
- * @param array       $block      The block being rendered.
- * @return null
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $parsed_block The parsed block.
+ * @return array The same parsed block with elements classname added if appropriate.
</ins><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function wp_render_elements_support_styles( $pre_render, $block ) {
-       $block_type           = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
-       $element_block_styles = isset( $block['attrs']['style']['elements'] ) ? $block['attrs']['style']['elements'] : null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function wp_render_elements_support_styles( $parsed_block ) {
+       /*
+        * The generation of element styles and classname were moved to the
+        * `render_block_data` filter in 6.6.0 to avoid filtered attributes
+        * breaking the application of the elements CSS class.
+        *
+        * @see https://github.com/WordPress/gutenberg/pull/59535.
+        *
+        * The change in filter means, the argument types for this function
+        * have changed and require deprecating.
+        */
+       if ( is_string( $parsed_block ) ) {
+               _deprecated_argument(
+                       __FUNCTION__,
+                       '6.6.0',
+                       __( 'Use as a `pre_render_block` filter is deprecated. Use with `render_block_data` instead.' )
+               );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        $block_type           = WP_Block_Type_Registry::get_instance()->get_registered( $parsed_block['blockName'] );
+       $element_block_styles = isset( $parsed_block['attrs']['style']['elements'] ) ? $parsed_block['attrs']['style']['elements'] : null;
+
</ins><span class="cx" style="display: block; padding: 0 10px">         if ( ! $element_block_styles ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                return null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         return $parsed_block;
</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">        $skip_link_color_serialization         = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -155,11 +162,25 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $skip_button_color_serialization;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( $skips_all_element_color_serialization ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                return null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         return $parsed_block;
</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">-        $class_name = wp_get_elements_class_name( $block );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $options = array(
+               'button'  => array( 'skip' => $skip_button_color_serialization ),
+               'link'    => array( 'skip' => $skip_link_color_serialization ),
+               'heading' => array( 'skip' => $skip_heading_color_serialization ),
+       );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( ! wp_should_add_elements_class_name( $parsed_block, $options ) ) {
+               return $parsed_block;
+       }
+
+       $class_name         = wp_get_elements_class_name( $parsed_block );
+       $updated_class_name = isset( $parsed_block['attrs']['className'] ) ? $parsed_block['attrs']['className'] . " $class_name" : $class_name;
+
+       _wp_array_set( $parsed_block, array( 'attrs', 'className' ), $updated_class_name );
+
+       // Generate element styles based on selector and store in style engine for enqueuing.
</ins><span class="cx" style="display: block; padding: 0 10px">         $element_types = array(
</span><span class="cx" style="display: block; padding: 0 10px">                'button'  => array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'selector' => ".$class_name .wp-element-button, .$class_name .wp-block-button__link",
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -225,8 +246,38 @@
</span><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"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        return null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $parsed_block;
</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">-add_filter( 'render_block', 'wp_render_elements_support', 10, 2 );
-add_filter( 'pre_render_block', 'wp_render_elements_support_styles', 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Ensure the elements block support class name generated, and added to
+ * block attributes, in the `render_block_data` filter gets applied to the
+ * block's markup.
+ *
+ * @see wp_render_elements_support_styles
+ * @since 6.6.0
+ *
+ * @param  string $block_content Rendered block content.
+ * @param  array  $block         Block object.
+ *
+ * @return string                Filtered block content.
+ */
+function wp_render_elements_class_name( $block_content, $block ) {
+       $class_string = $block['attrs']['className'] ?? '';
+       preg_match( '/\bwp-elements-\S+\b/', $class_string, $matches );
+
+       if ( empty( $matches ) ) {
+               return $block_content;
+       }
+
+       $tags = new WP_HTML_Tag_Processor( $block_content );
+
+       if ( $tags->next_tag() ) {
+               $tags->add_class( $matches[0] );
+       }
+
+       return $tags->get_updated_html();
+}
+
+add_filter( 'render_block', 'wp_render_elements_class_name', 10, 2 );
+add_filter( 'render_block_data', 'wp_render_elements_support_styles', 10, 1 );
</ins></span></pre></div>
<a id="trunktestsphpunittestsblocksupportswpRenderElementsSupportphp"></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/wpRenderElementsSupport.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/block-supports/wpRenderElementsSupport.php      2024-05-01 23:59:03 UTC (rev 58073)
+++ trunk/tests/phpunit/tests/block-supports/wpRenderElementsSupport.php        2024-05-02 06:59:30 UTC (rev 58074)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,7 +44,7 @@
</span><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">                $block_markup = '<p>Hello <a href="http://www.wordpress.org/">WordPress</a>!</p>';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $actual       = wp_render_elements_support( $block_markup, $block );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $actual       = wp_render_elements_class_name( $block_markup, $block );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( $block_markup, $actual, 'Expected to leave block content unmodified, but found changes.' );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -90,7 +90,14 @@
</span><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"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $actual = wp_render_elements_support( $block_markup, $block );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /*
+                * To ensure a consistent elements class name it is generated within a
+                * `render_block_data` filter and stored in the `className` attribute.
+                * As a result, the block data needs to be passed through the same
+                * function for this test.
+                */
+               $filtered_block = wp_render_elements_support_styles( $block );
+               $actual         = wp_render_elements_class_name( $block_markup, $filtered_block );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertMatchesRegularExpression(
</span><span class="cx" style="display: block; padding: 0 10px">                        $expected_markup,
</span></span></pre></div>
<a id="trunktestsphpunittestsblocksupportswpRenderElementsSupportStylesphp"></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/wpRenderElementsSupportStyles.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php        2024-05-01 23:59:03 UTC (rev 58073)
+++ trunk/tests/phpunit/tests/block-supports/wpRenderElementsSupportStyles.php  2024-05-02 06:59:30 UTC (rev 58074)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,7 +59,7 @@
</span><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"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_render_elements_support_styles( null, $block );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_render_elements_support_styles( $block );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $actual_stylesheet = wp_style_engine_get_stylesheet_from_context( 'block-supports', array( 'prettify' => false ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertMatchesRegularExpression(
</span></span></pre>
</div>
</div>

</body>
</html>