<!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>[60951] trunk: Editor: Opt to dequeue assets enqueued in hidden blocks, rather than to enqueue assets for non-hidden blocks.</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/60951">60951</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/60951","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>westonruter</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2025-10-16 23:30:56 +0000 (Thu, 16 Oct 2025)</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: Opt to dequeue assets enqueued in hidden blocks, rather than to enqueue assets for non-hidden blocks.

This eliminates constant emptying out of the queues for styles, scripts, and script modules before rendering each block. This ensures that `wp_script_is()`/`wp_style_is()` will return true for assets that are actually enqueued. The `WP_Script_Modules::$queue` member which was made public in <a href="https://core.trac.wordpress.org/changeset/60930">[60930]</a> is now made private in favor of a `WP_Script_Modules::get_queue()` method, since there is no need to clear out the queue before rendering each block and restore after the rendering is complete. 

Finally, as a very special case for unusual blocks which contain `wp_head()`, a check is done to see if the `wp_enqueue_scripts` action occurred during the rendering of a block; if so, then no assets will be dequeued even if no markup is rendered in the block, since it may be that a script was enqueued for the footer and not the head. 

Developed in https://github.com/WordPress/wordpress-develop/pull/10252

Follow-up to <a href="https://core.trac.wordpress.org/changeset/60930">[60930]</a>.

Props westonruter, dd32, peterwilsoncc, nikunj8866, krupajnanda.
Fixes <a href="https://core.trac.wordpress.org/ticket/63676">#63676</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpblockphp">trunk/src/wp-includes/class-wp-block.php</a></li>
<li><a href="#trunksrcwpincludesclasswpscriptmodulesphp">trunk/src/wp-includes/class-wp-script-modules.php</a></li>
<li><a href="#trunktestsphpunittestsblockswpBlockphp">trunk/tests/phpunit/tests/blocks/wpBlock.php</a></li>
<li><a href="#trunktestsphpunittestsscriptmoduleswpScriptModulesphp">trunk/tests/phpunit/tests/script-modules/wpScriptModules.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpblockphp"></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/class-wp-block.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-block.php  2025-10-16 23:17:14 UTC (rev 60950)
+++ trunk/src/wp-includes/class-wp-block.php    2025-10-16 23:30:56 UTC (rev 60951)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -492,13 +492,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function render( $options = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px">                global $post;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Capture the current assets queues and then clear out to capture the diff of what was introduced by rendering.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $before_wp_enqueue_scripts_count = did_action( 'wp_enqueue_scripts' );
+
+               // Capture the current assets queues.
</ins><span class="cx" style="display: block; padding: 0 10px">                 $before_styles_queue         = wp_styles()->queue;
</span><span class="cx" style="display: block; padding: 0 10px">                $before_scripts_queue        = wp_scripts()->queue;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $before_script_modules_queue = wp_script_modules()->queue;
-               wp_styles()->queue           = array();
-               wp_scripts()->queue          = array();
-               wp_script_modules()->queue   = array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $before_script_modules_queue = wp_script_modules()->get_queue();
</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">                 * There can be only one root interactive block at a time because the rendered HTML of that block contains
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -670,21 +669,27 @@
</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">                // Capture the new assets enqueued during rendering, and restore the queues the state prior to rendering.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $new_styles_queue          = wp_styles()->queue;
-               $new_scripts_queue         = wp_scripts()->queue;
-               $new_script_modules_queue  = wp_script_modules()->queue;
-               wp_styles()->queue         = $before_styles_queue;
-               wp_scripts()->queue        = $before_scripts_queue;
-               wp_script_modules()->queue = $before_script_modules_queue;
-               $has_new_styles            = count( $new_styles_queue ) > 0;
-               $has_new_scripts           = count( $new_scripts_queue ) > 0;
-               $has_new_script_modules    = count( $new_script_modules_queue ) > 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $after_styles_queue         = wp_styles()->queue;
+               $after_scripts_queue        = wp_scripts()->queue;
+               $after_script_modules_queue = wp_script_modules()->get_queue();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Merge the newly enqueued assets with the existing assets if the rendered block is not empty.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /*
+                * As a very special case, a dynamic block may in fact include a call to wp_head() (and thus wp_enqueue_scripts()),
+                * in which all of its enqueued assets are targeting wp_footer. In this case, nothing would be printed, but this
+                * shouldn't indicate that the just-enqueued assets should be dequeued due to it being an empty block.
+                */
+               $just_did_wp_enqueue_scripts = ( did_action( 'wp_enqueue_scripts' ) !== $before_wp_enqueue_scripts_count );
+
+               $has_new_styles         = ( $before_styles_queue !== $after_styles_queue );
+               $has_new_scripts        = ( $before_scripts_queue !== $after_scripts_queue );
+               $has_new_script_modules = ( $before_script_modules_queue !== $after_script_modules_queue );
+
+               // Dequeue the newly enqueued assets with the existing assets if the rendered block was empty & wp_enqueue_scripts did not fire.
</ins><span class="cx" style="display: block; padding: 0 10px">                 if (
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        ! $just_did_wp_enqueue_scripts &&
</ins><span class="cx" style="display: block; padding: 0 10px">                         ( $has_new_styles || $has_new_scripts || $has_new_script_modules ) &&
</span><span class="cx" style="display: block; padding: 0 10px">                        (
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                trim( $block_content ) !== '' ||
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         trim( $block_content ) === '' &&
</ins><span class="cx" style="display: block; padding: 0 10px">                                 /**
</span><span class="cx" style="display: block; padding: 0 10px">                                 * Filters whether to enqueue assets for a block which has no rendered content.
</span><span class="cx" style="display: block; padding: 0 10px">                                 *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -693,17 +698,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                 * @param bool   $enqueue    Whether to enqueue assets.
</span><span class="cx" style="display: block; padding: 0 10px">                                 * @param string $block_name Block name.
</span><span class="cx" style="display: block; padding: 0 10px">                                 */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                (bool) apply_filters( 'enqueue_empty_block_content_assets', false, $this->name )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         ! (bool) apply_filters( 'enqueue_empty_block_content_assets', false, $this->name )
</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 ( $has_new_styles ) {
-                               wp_styles()->queue = array_unique( array_merge( wp_styles()->queue, $new_styles_queue ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 foreach ( array_diff( $after_styles_queue, $before_styles_queue ) as $handle ) {
+                               wp_dequeue_style( $handle );
</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 ( $has_new_scripts ) {
-                               wp_scripts()->queue = array_unique( array_merge( wp_scripts()->queue, $new_scripts_queue ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 foreach ( array_diff( $after_scripts_queue, $before_scripts_queue ) as $handle ) {
+                               wp_dequeue_script( $handle );
</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 ( $has_new_script_modules ) {
-                               wp_script_modules()->queue = array_unique( array_merge( wp_script_modules()->queue, $new_script_modules_queue ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 foreach ( array_diff( $after_script_modules_queue, $before_script_modules_queue ) as $handle ) {
+                               wp_dequeue_script_module( $handle );
</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></pre></div>
<a id="trunksrcwpincludesclasswpscriptmodulesphp"></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/class-wp-script-modules.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-script-modules.php 2025-10-16 23:17:14 UTC (rev 60950)
+++ trunk/src/wp-includes/class-wp-script-modules.php   2025-10-16 23:30:56 UTC (rev 60951)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -28,7 +28,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 6.9.0
</span><span class="cx" style="display: block; padding: 0 10px">         * @var string[]
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public $queue = array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private $queue = array();
</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">         * Tracks whether the @wordpress/a11y script module is available.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -138,6 +138,17 @@
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Gets IDs for queued script modules.
+        *
+        * @since 6.9.0
+        *
+        * @return string[] Script module IDs.
+        */
+       public function get_queue(): array {
+               return $this->queue;
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Checks if the provided fetchpriority is valid.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 6.9.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -237,7 +248,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $id The identifier of the script module.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function dequeue( string $id ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->queue = array_diff( $this->queue, array( $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->queue = array_values( array_diff( $this->queue, array( $id ) ) );
</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></pre></div>
<a id="trunktestsphpunittestsblockswpBlockphp"></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/blocks/wpBlock.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/wpBlock.php      2025-10-16 23:17:14 UTC (rev 60950)
+++ trunk/tests/phpunit/tests/blocks/wpBlock.php        2025-10-16 23:30:56 UTC (rev 60951)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -543,6 +543,62 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'expected_scripts'        => array( 'static-view-script', 'static-child-view-script', 'dynamic-view-script' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                'expected_script_modules' => array( 'static-view-script-module', 'static-child-view-script-module', 'dynamic-view-script-module' ),
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'admin_bar_assets_enqueued_in_block'      => array(
+                               'set_up'                  => static function () {
+                                       wp_enqueue_script( 'admin-bar' );
+                                       wp_enqueue_style( 'admin-bar' );
+
+                                       add_filter(
+                                               'render_block_core/static',
+                                               static function ( $content ) {
+                                                       $processor = new WP_HTML_Tag_Processor( $content );
+                                                       $processor->next_tag();
+                                                       $processor->add_class( wp_script_is( 'admin-bar', 'enqueued' ) ? 'yes-admin-bar-script-enqueued' : 'not-admin-bar-script-enqueued' );
+                                                       $processor->add_class( wp_style_is( 'admin-bar', 'enqueued' ) ? 'yes-admin-bar-style-enqueued' : 'not-admin-bar-style-enqueued' );
+                                                       return $processor->get_updated_html();
+                                               },
+                                               10,
+                                               3
+                                       );
+                               },
+                               'block_markup'            => '<!-- wp:static --><div class="static"></div><!-- /wp:static -->',
+                               'expected_rendered_block' => '
+                                       <div class="static yes-admin-bar-script-enqueued yes-admin-bar-style-enqueued"></div>
+                               ',
+                               'expected_styles'         => array( 'static-view-style', 'admin-bar' ),
+                               'expected_scripts'        => array( 'static-view-script', 'admin-bar' ),
+                               'expected_script_modules' => array( 'static-view-script-module' ),
+                       ),
+                       'enqueues_in_wp_head_block'               => array(
+                               'set_up'                  => static function () {
+                                       remove_all_actions( 'wp_head' );
+                                       remove_all_actions( 'wp_enqueue_scripts' );
+
+                                       add_action( 'wp_head', 'wp_enqueue_scripts', 1 );
+                                       add_action( 'wp_head', 'wp_print_styles', 8 );
+                                       add_action( 'wp_head', 'wp_print_head_scripts', 9 );
+                                       remove_action( 'wp_print_styles', 'print_emoji_styles' );
+
+                                       add_action(
+                                               'wp_enqueue_scripts',
+                                               static function () {
+                                                       wp_enqueue_script( 'for-footer', '/footer.js', array(), null, array( 'in_footer' => true ) );
+                                               }
+                                       );
+                                       add_action(
+                                               'wp_head',
+                                               static function () {
+                                                       wp_enqueue_style( 'for-footer', '/footer.css', array(), null );
+                                               },
+                                               10000
+                                       );
+                               },
+                               'block_markup'            => '<!-- wp:wp-head /-->',
+                               'expected_rendered_block' => '',
+                               'expected_styles'         => array( 'for-footer' ),
+                               'expected_scripts'        => array( 'for-footer' ),
+                               'expected_script_modules' => array(),
+                       ),
</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="lines" style="display: block; padding: 0 10px; color: #888">@@ -562,6 +618,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                if ( $set_up instanceof Closure ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $set_up();
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->registry->register(
+                       'core/wp-head',
+                       array(
+                               'render_callback' => static function () {
+                                       return get_echo( 'wp_head' );
+                               },
+                       )
+               );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 wp_register_style( 'static-view-style', home_url( '/static-view-style.css' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                wp_register_script( 'static-view-script', home_url( '/static-view-script.js' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                wp_register_script_module( 'static-view-script-module', home_url( '/static-view-script-module.js' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -608,6 +674,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $block          = new WP_Block( $parsed_block, $context, $this->registry );
</span><span class="cx" style="display: block; padding: 0 10px">                $rendered_block = $block->render();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $this->assertSameSets( $expected_styles, wp_styles()->queue, 'Enqueued styles do not meet expectations' );
+               $this->assertSameSets( $expected_scripts, wp_scripts()->queue, 'Enqueued scripts do not meet expectations' );
+               $this->assertSameSets( $expected_script_modules, wp_script_modules()->get_queue(), 'Enqueued script modules do not meet expectations' );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertEqualHTML(
</span><span class="cx" style="display: block; padding: 0 10px">                        $expected_rendered_block,
</span><span class="cx" style="display: block; padding: 0 10px">                        $rendered_block,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -614,38 +684,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '<body>',
</span><span class="cx" style="display: block; padding: 0 10px">                        "Rendered block does not contain expected HTML:\n$rendered_block"
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-               remove_action( 'wp_print_styles', 'print_emoji_styles' );
-
-               $actual_styles  = array();
-               $printed_styles = get_echo( 'wp_print_styles' );
-               $processor      = new WP_HTML_Tag_Processor( $printed_styles );
-               while ( $processor->next_tag( array( 'tag_name' => 'LINK' ) ) ) {
-                       if ( 1 === preg_match( '/^(.+)-css$/', $processor->get_attribute( 'id' ), $matches ) ) {
-                               $actual_styles[] = $matches[1];
-                       }
-               }
-               $this->assertSameSets( $expected_styles, $actual_styles, 'Enqueued styles do not meet expectations' );
-
-               $actual_scripts  = array();
-               $printed_scripts = get_echo( 'wp_print_scripts' );
-               $processor       = new WP_HTML_Tag_Processor( $printed_scripts );
-               while ( $processor->next_tag( array( 'tag_name' => 'SCRIPT' ) ) ) {
-                       if ( 1 === preg_match( '/^(.+)-js$/', $processor->get_attribute( 'id' ), $matches ) ) {
-                               $actual_scripts[] = $matches[1];
-                       }
-               }
-               $this->assertSameSets( $expected_scripts, $actual_scripts, 'Enqueued scripts do not meet expectations' );
-
-               $actual_script_modules  = array();
-               $printed_script_modules = get_echo( array( wp_script_modules(), 'print_enqueued_script_modules' ) );
-               $processor              = new WP_HTML_Tag_Processor( $printed_script_modules );
-               while ( $processor->next_tag( array( 'tag_name' => 'SCRIPT' ) ) ) {
-                       if ( 1 === preg_match( '/^(.+)-js-module$/', $processor->get_attribute( 'id' ), $matches ) ) {
-                               $actual_script_modules[] = $matches[1];
-                       }
-               }
-               $this->assertSameSets( $expected_script_modules, $actual_script_modules, 'Enqueued script modules do not meet expectations' );
</del><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></pre></div>
<a id="trunktestsphpunittestsscriptmoduleswpScriptModulesphp"></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/script-modules/wpScriptModules.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/script-modules/wpScriptModules.php      2025-10-16 23:17:14 UTC (rev 60950)
+++ trunk/tests/phpunit/tests/script-modules/wpScriptModules.php        2025-10-16 23:30:56 UTC (rev 60951)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1676,10 +1676,11 @@
</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">-         * Tests that directly manipulating the queue works as expected.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Tests that manipulating the queue works as expected.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 63676
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @covers WP_Script_Modules::get_queue
</ins><span class="cx" style="display: block; padding: 0 10px">          * @covers WP_Script_Modules::queue
</span><span class="cx" style="display: block; padding: 0 10px">         * @covers WP_Script_Modules::dequeue
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1687,17 +1688,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->script_modules->register( 'foo', '/foo.js' );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->script_modules->register( 'bar', '/bar.js' );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->script_modules->register( 'baz', '/baz.js' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertSame( array(), $this->script_modules->queue, 'Expected queue to be empty.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( array(), $this->script_modules->get_queue(), 'Expected queue to be empty.' );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->script_modules->enqueue( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->script_modules->enqueue( 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->script_modules->enqueue( 'bar' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertSame( array( 'foo', 'bar' ), $this->script_modules->queue, 'Expected two deduplicated queued items.' );
-               $this->script_modules->queue = array( 'baz' );
-               $this->script_modules->enqueue( 'bar' );
-               $this->assertSame( array( 'baz', 'bar' ), $this->script_modules->queue, 'Expected queue updated via setter and enqueue method to have two items.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( array( 'foo', 'bar' ), $this->script_modules->get_queue(), 'Expected two deduplicated queued items.' );
+               $this->script_modules->dequeue( 'foo' );
+               $this->script_modules->dequeue( 'foo' );
+               $this->script_modules->enqueue( 'baz' );
+               $this->assertSame( array( 'bar', 'baz' ), $this->script_modules->get_queue(), 'Expected items tup be updated after dequeue and enqueue.' );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->script_modules->dequeue( 'baz' );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->script_modules->dequeue( 'bar' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertSame( array(), $this->script_modules->queue, 'Expected queue to be empty after dequeueing both items.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( array(), $this->script_modules->get_queue(), 'Expected queue to be empty after dequeueing both items.' );
</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></pre>
</div>
</div>

</body>
</html>