<!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>[57649] trunk: Interactivity API: Skip instead of bail out if HTML contains `SVG` or `MATH`.</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/57649">57649</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/57649","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>swissspidy</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-02-17 15:26:43 +0000 (Sat, 17 Feb 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'>Interactivity API: Skip instead of bail out if HTML contains `SVG` or `MATH`.

Addresses an issue with server-side processing of directives when there is e.g. an SVG icon a navigation menu.

Props cbravobernal, westonruter, dmsnell, swissspidy.
Fixes <a href="https://core.trac.wordpress.org/ticket/60517">#60517</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesinteractivityapiclasswpinteractivityapidirectivesprocessorphp">trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php</a></li>
<li><a href="#trunksrcwpincludesinteractivityapiclasswpinteractivityapiphp">trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api.php</a></li>
<li><a href="#trunktestsphpunittestsinteractivityapiwpInteractivityAPIphp">trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php</a></li>
<li><a href="#trunktestsphpunittestsinteractivityapiwpInteractivityAPIDirectivesProcessorphp">trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPIDirectivesProcessor.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesinteractivityapiclasswpinteractivityapidirectivesprocessorphp"></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/interactivity-api/class-wp-interactivity-api-directives-processor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php       2024-02-17 15:22:37 UTC (rev 57648)
+++ trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php 2024-02-17 15:26:43 UTC (rev 57649)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -181,6 +181,39 @@
</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">+         * Skips processing the content between tags.
+        *
+        * It positions the cursor in the closer tag of the foreign element, if it
+        * exists.
+        *
+        * This function is intended to skip processing SVG and MathML inner content
+        * instead of bailing out the whole processing.
+        *
+        * @since 6.5.0
+        *
+        * @access private
+        *
+        * @return bool Whether the foreign content was successfully skipped.
+        */
+       public function skip_to_tag_closer(): bool {
+               $depth    = 1;
+               $tag_name = $this->get_tag();
+               while ( $depth > 0 && $this->next_tag(
+                       array(
+                               'tag_name'    => $tag_name,
+                               'tag_closers' => 'visit',
+                       )
+               ) ) {
+                       if ( $this->has_self_closing_flag() ) {
+                               continue;
+                       }
+                       $depth += $this->is_tag_closer() ? -1 : 1;
+               }
+
+               return 0 === $depth;
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Finds the matching closing tag for an opening tag.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * When called while the processor is on an open tag, it traverses the HTML
</span></span></pre></div>
<a id="trunksrcwpincludesinteractivityapiclasswpinteractivityapiphp"></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/interactivity-api/class-wp-interactivity-api.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api.php    2024-02-17 15:22:37 UTC (rev 57648)
+++ trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api.php      2024-02-17 15:26:43 UTC (rev 57649)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -235,9 +235,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                while ( $p->next_tag( array( 'tag_closers' => 'visit' ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $tag_name = $p->get_tag();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        /*
+                        * Directives inside SVG and MATH tags are not processed,
+                        * as they are not compatible with the Tag Processor yet.
+                        * We still process the rest of the HTML.
+                        */
</ins><span class="cx" style="display: block; padding: 0 10px">                         if ( 'SVG' === $tag_name || 'MATH' === $tag_name ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $unbalanced = true;
-                               break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $p->skip_to_tag_closer();
+                               continue;
</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">                        if ( $p->is_tag_closer() ) {
</span></span></pre></div>
<a id="trunktestsphpunittestsinteractivityapiwpInteractivityAPIphp"></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/interactivity-api/wpInteractivityAPI.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php        2024-02-17 15:22:37 UTC (rev 57648)
+++ trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php  2024-02-17 15:26:43 UTC (rev 57649)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,7 +11,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @coversDefaultClass WP_Interactivity_API
</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 Tests_WP_Interactivity_API extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class Tests_Interactivity_API_WpInteractivityAPI extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Instance of WP_Interactivity_API.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -508,54 +508,135 @@
</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 the `process_directives` returns the same HTML if it finds an
-        * SVG tag.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Tests that the `process_directives` process the HTML outside a SVG tag.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @ticket 60356
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @ticket 60517
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @covers ::process_directives
</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 function test_process_directives_doesnt_change_html_if_contains_svgs() {
-               $this->interactivity->state( 'myPlugin', array( 'id' => 'some-id' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_process_directives_changes_html_if_contains_svgs() {
+               $this->interactivity->state(
+                       'myPlugin',
+                       array(
+                               'id'    => 'some-id',
+                               'width' => '100',
+                       )
+               );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $html           = '
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <div data-wp-bind--id="myPlugin::state.id">
-                               <svg height="100" width="100">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <header>
+                               <svg height="100" data-wp-bind--width="myPlugin::state.width">
+                                       <title>Red Circle</title>
</ins><span class="cx" style="display: block; padding: 0 10px">                                         <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                </svg> 
-                       </div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         </svg>
+                               <div data-wp-bind--id="myPlugin::state.id"></div>
+                               <div data-wp-bind--id="myPlugin::state.width"></div>
+                       </header>
</ins><span class="cx" style="display: block; padding: 0 10px">                 ';
</span><span class="cx" style="display: block; padding: 0 10px">                $processed_html = $this->interactivity->process_directives( $html );
</span><span class="cx" style="display: block; padding: 0 10px">                $p              = new WP_HTML_Tag_Processor( $processed_html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $p->next_tag( 'svg' );
+               $this->assertNull( $p->get_attribute( 'width' ) );
+               $p->next_tag( 'div' );
+               $this->assertEquals( 'some-id', $p->get_attribute( 'id' ) );
+               $p->next_tag( 'div' );
+               $this->assertEquals( '100', $p->get_attribute( 'id' ) );
+       }
+
+       /**
+        * Tests that the `process_directives` does not process the HTML
+        * inside SVG tags.
+        *
+        * @ticket 60517
+        *
+        * @covers ::process_directives
+        */
+       public function test_process_directives_does_not_change_inner_html_in_svgs() {
+               $this->interactivity->state(
+                       'myPlugin',
+                       array(
+                               'id' => 'some-id',
+                       )
+               );
+               $html           = '
+                       <header>
+                               <svg height="100">
+                                       <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
+                                       <g data-wp-bind--id="myPlugin::state.id" />
+                               </svg>
+                       </header>
+               ';
+               $processed_html = $this->interactivity->process_directives( $html );
+               $p              = new WP_HTML_Tag_Processor( $processed_html );
+               $p->next_tag( 'div' );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertNull( $p->get_attribute( 'id' ) );
</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 the `process_directives` returns the same HTML if it finds an
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Tests that the `process_directives` process the HTML outside the
</ins><span class="cx" style="display: block; padding: 0 10px">          * MathML tag.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @ticket 60356
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @ticket 60517
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @covers ::process_directives
</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 function test_process_directives_doesnt_change_html_if_contains_math() {
-               $this->interactivity->state( 'myPlugin', array( 'id' => 'some-id' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_process_directives_change_html_if_contains_math() {
+               $this->interactivity->state(
+                       'myPlugin',
+                       array(
+                               'id'   => 'some-id',
+                               'math' => 'ml-id',
+                       )
+               );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $html           = '
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <div data-wp-bind--id="myPlugin::state.id">
-                               <math>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <header>
+                               <math data-wp-bind--id="myPlugin::state.math">
</ins><span class="cx" style="display: block; padding: 0 10px">                                         <mi>x</mi>
</span><span class="cx" style="display: block; padding: 0 10px">                                        <mo>=</mo>
</span><span class="cx" style="display: block; padding: 0 10px">                                        <mi>1</mi>
</span><span class="cx" style="display: block; padding: 0 10px">                                </math>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        </div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         <div data-wp-bind--id="myPlugin::state.id"></div>
+                       </header>
</ins><span class="cx" style="display: block; padding: 0 10px">                 ';
</span><span class="cx" style="display: block; padding: 0 10px">                $processed_html = $this->interactivity->process_directives( $html );
</span><span class="cx" style="display: block; padding: 0 10px">                $p              = new WP_HTML_Tag_Processor( $processed_html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $p->next_tag( 'math' );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertNull( $p->get_attribute( 'id' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $p->next_tag( 'div' );
+               $this->assertEquals( 'some-id', $p->get_attribute( '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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Tests that the `process_directives` does not process the HTML
+        * inside MathML tags.
+        *
+        * @ticket 60517
+        *
+        * @covers ::process_directives
+        */
+       public function test_process_directives_does_not_change_inner_html_in_math() {
+               $this->interactivity->state(
+                       'myPlugin',
+                       array(
+                               'id' => 'some-id',
+                       )
+               );
+               $html           = '
+                       <header>
+                               <math data-wp-bind--id="myPlugin::state.math">
+                                       <mrow data-wp-bind--id="myPlugin::state.id" />
+                                       <mi>x</mi>
+                                       <mo>=</mo>
+                                       <mi>1</mi>
+                               </math>
+                       </header>
+               ';
+               $processed_html = $this->interactivity->process_directives( $html );
+               $p              = new WP_HTML_Tag_Processor( $processed_html );
+               $p->next_tag( 'div' );
+               $this->assertNull( $p->get_attribute( 'id' ) );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Invokes the private `evaluate` method of WP_Interactivity_API class.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $directive_value The directive attribute value to evaluate.
</span></span></pre></div>
<a id="trunktestsphpunittestsinteractivityapiwpInteractivityAPIDirectivesProcessorphp"></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/interactivity-api/wpInteractivityAPIDirectivesProcessor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPIDirectivesProcessor.php     2024-02-17 15:22:37 UTC (rev 57648)
+++ trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPIDirectivesProcessor.php       2024-02-17 15:26:43 UTC (rev 57649)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,7 +11,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @coversDefaultClass WP_Interactivity_API_Directives_Processor
</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 Tests_WP_Interactivity_API_Directives_Processor extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class Tests_Interactivity_API_WpInteractivityAPIDirectivesProcessor extends WP_UnitTestCase {
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Tests the `get_content_between_balanced_template_tags` method on template
</span><span class="cx" style="display: block; padding: 0 10px">         * tags.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -778,4 +778,51 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $p->next_tag( array( 'tag_closers' => 'visit' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertFalse( $p->next_balanced_tag_closer_tag() );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Tests that skip_to_tag_closer skips to the next tag,
+        * independant of the content.
+        *
+        * @ticket 60517
+        *
+        * @covers ::skip_to_tag_closer
+        */
+       public function test_skip_to_tag_closer() {
+               $content = '<div><span>Not closed</div>';
+               $p       = new WP_Interactivity_API_Directives_Processor( $content );
+               $p->next_tag();
+               $this->assertTrue( $p->skip_to_tag_closer() );
+               $this->assertTrue( $p->is_tag_closer() );
+               $this->assertEquals( 'DIV', $p->get_tag() );
+       }
+
+       /**
+        * Tests that skip_to_tag_closer does not skip to the
+        * next tag if there is no closing tag.
+        *
+        * @ticket 60517
+        *
+        * @covers ::skip_to_tag_closer
+        */
+       public function test_skip_to_tag_closer_bails_not_closed() {
+               $content = '<div>Not closed parent';
+               $p       = new WP_Interactivity_API_Directives_Processor( $content );
+               $p->next_tag();
+               $this->assertFalse( $p->skip_to_tag_closer() );
+       }
+
+       /**
+        * Tests that skip_to_tag_closer does not skip to the next
+        * tag if the closing tag is different from the current tag.
+        *
+        * @ticket 60517
+        *
+        * @covers ::skip_to_tag_closer
+        */
+       public function test_skip_to_tag_closer_bails_different_tags() {
+               $content = '<div></span>';
+               $p       = new WP_Interactivity_API_Directives_Processor( $content );
+               $p->next_tag();
+               $this->assertFalse( $p->skip_to_tag_closer() );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>