<!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>[57508] trunk/tests/phpunit/tests/html-api: HTML API: Test cleanup</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/57508">57508</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/57508","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dmsnell</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-02-01 01:00:56 +0000 (Thu, 01 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'>HTML API: Test cleanup
Rename `$p` variable to `$processor` in tests for clarity.
Use static data providers. A mix of static and non-static data providers were
used in HTML API tests. Data providers are required to be static in the next
PHPUnit version and there's no harm in using them consistently now.
Follow-up to <a href="https://core.trac.wordpress.org/changeset/57507">[57507]</a>
Props jonsurrell
See <a href="https://core.trac.wordpress.org/ticket/59647">#59647</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestshtmlapiwpHtmlProcessorphp">trunk/tests/phpunit/tests/html-api/wpHtmlProcessor.php</a></li>
<li><a href="#trunktestsphpunittestshtmlapiwpHtmlProcessorBreadcrumbsphp">trunk/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php</a></li>
<li><a href="#trunktestsphpunittestshtmlapiwpHtmlProcessorSemanticRulesphp">trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php</a></li>
<li><a href="#trunktestsphpunittestshtmlapiwpHtmlProcessorSemanticRulesHeadingElementsphp">trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRulesHeadingElements.php</a></li>
<li><a href="#trunktestsphpunittestshtmlapiwpHtmlSupportRequiredHtmlProcessorphp">trunk/tests/phpunit/tests/html-api/wpHtmlSupportRequiredHtmlProcessor.php</a></li>
<li><a href="#trunktestsphpunittestshtmlapiwpHtmlSupportRequiredOpenElementsphp">trunk/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php</a></li>
<li><a href="#trunktestsphpunittestshtmlapiwpHtmlTagProcessorbookmarkphp">trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php</a></li>
<li><a href="#trunktestsphpunittestshtmlapiwpHtmlTagProcessortokenscanningphp">trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php</a></li>
<li><a href="#trunktestsphpunittestshtmlapiwpHtmlTagProcessorphp">trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestshtmlapiwpHtmlProcessorphp"></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/html-api/wpHtmlProcessor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/html-api/wpHtmlProcessor.php 2024-02-01 00:41:40 UTC (rev 57507)
+++ trunk/tests/phpunit/tests/html-api/wpHtmlProcessor.php 2024-02-01 01:00:56 UTC (rev 57508)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -52,12 +52,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Processor::get_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_tag_is_null_once_document_is_finished() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<div class="test">Test</div>' );
- $p->next_tag();
- $this->assertSame( 'DIV', $p->get_tag() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<div class="test">Test</div>' );
+ $processor->next_tag();
+ $this->assertSame( 'DIV', $processor->get_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">- $this->assertFalse( $p->next_tag() );
- $this->assertNull( $p->get_tag() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->next_tag() );
+ $this->assertNull( $processor->get_tag() );
</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">@@ -77,44 +77,44 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Processor::seek
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_clear_to_navigate_after_seeking() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<div one><strong></strong></div><p><strong two></strong></p>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<div one><strong></strong></div><p><strong two></strong></p>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- while ( $p->next_tag() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ while ( $processor->next_tag() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // Create a bookmark before entering a stack of elements and formatting elements.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( null !== $p->get_attribute( 'one' ) ) {
- $this->assertTrue( $p->set_bookmark( 'one' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( null !== $processor->get_attribute( 'one' ) ) {
+ $this->assertTrue( $processor->set_bookmark( 'one' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</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"> // Create a bookmark inside of that stack.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( null !== $p->get_attribute( 'two' ) ) {
- $p->set_bookmark( 'two' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( null !== $processor->get_attribute( 'two' ) ) {
+ $processor->set_bookmark( 'two' );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</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><span class="cx" style="display: block; padding: 0 10px"> // Ensure that it's possible to seek back to the outside location.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->seek( 'one' ), 'Could not seek to earlier-seen location.' );
- $this->assertSame( 'DIV', $p->get_tag(), "Should have jumped back to DIV but found {$p->get_tag()} instead." );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->seek( 'one' ), 'Could not seek to earlier-seen location.' );
+ $this->assertSame( 'DIV', $processor->get_tag(), "Should have jumped back to DIV but found {$processor->get_tag()} instead." );
</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"> * Ensure that the P element from the inner location isn't still on the stack of open elements.
</span><span class="cx" style="display: block; padding: 0 10px"> * If it were, then the first STRONG element, inside the outer DIV would match the next call.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( array( 'breadcrumbs' => array( 'P', 'STRONG' ) ) ), 'Failed to find given location after seeking.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( array( 'breadcrumbs' => array( 'P', 'STRONG' ) ) ), 'Failed to find given location after seeking.' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Only if the stack is properly managed will the processor advance to the inner STRONG element.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->get_attribute( 'two' ), "Found the wrong location given the breadcrumbs, at {$p->get_tag()}." );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->get_attribute( 'two' ), "Found the wrong location given the breadcrumbs, at {$processor->get_tag()}." );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Ensure that in seeking backwards the processor reports the correct full set of breadcrumbs.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->seek( 'one' ), 'Failed to jump back to first bookmark.' );
- $this->assertSame( array( 'HTML', 'BODY', 'DIV' ), $p->get_breadcrumbs(), 'Found wrong set of breadcrumbs navigating to node "one".' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->seek( 'one' ), 'Failed to jump back to first bookmark.' );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV' ), $processor->get_breadcrumbs(), 'Found wrong set of breadcrumbs navigating to node "one".' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Ensure that in seeking forwards the processor reports the correct full set of breadcrumbs.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->seek( 'two' ), 'Failed to jump forward to second bookmark.' );
- $this->assertTrue( $p->get_attribute( 'two' ), "Found the wrong location given the bookmark, at {$p->get_tag()}." );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->seek( 'two' ), 'Failed to jump forward to second bookmark.' );
+ $this->assertTrue( $processor->get_attribute( 'two' ), "Found the wrong location given the bookmark, at {$processor->get_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">- $this->assertSame( array( 'HTML', 'BODY', 'P', 'STRONG' ), $p->get_breadcrumbs(), 'Found wrong set of bookmarks navigating to node "two".' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( 'HTML', 'BODY', 'P', 'STRONG' ), $processor->get_breadcrumbs(), 'Found wrong set of bookmarks navigating to node "two".' );
</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">@@ -126,10 +126,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Processor::reconstruct_active_formatting_elements
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_fails_to_reconstruct_formatting_elements() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<p><em>One<p><em>Two<p><em>Three<p><em>Four' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<p><em>One<p><em>Two<p><em>Three<p><em>Four' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'EM' ), 'Could not find first EM.' );
- $this->assertFalse( $p->next_tag( 'EM' ), 'Should have aborted before finding second EM as it required reconstructing the first EM.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'EM' ), 'Could not find first EM.' );
+ $this->assertFalse( $processor->next_tag( 'EM' ), 'Should have aborted before finding second EM as it required reconstructing the first EM.' );
</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">@@ -246,7 +246,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_void_tags() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_void_tags() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'AREA' => array( 'AREA' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'BASE' => array( 'BASE' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -290,7 +290,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_unsupported_special_in_body_tags() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_unsupported_special_in_body_tags() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'APPLET' => array( 'APPLET' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'BASE' => array( 'BASE' ),
</span></span></pre></div>
<a id="trunktestsphpunittestshtmlapiwpHtmlProcessorBreadcrumbsphp"></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/html-api/wpHtmlProcessorBreadcrumbs.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php 2024-02-01 00:41:40 UTC (rev 57507)
+++ trunk/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php 2024-02-01 01:00:56 UTC (rev 57508)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -23,10 +23,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $tag_name Name of first tag in HTML (because HTML treats IMAGE as IMG this may not match the HTML).
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_navigates_into_normative_html_for_supported_elements( $html, $tag_name ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( $html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( $html );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->step(), "Failed to step into supported {$tag_name} element." );
- $this->assertSame( $tag_name, $p->get_tag(), "Misread {$tag_name} as a {$p->get_tag()} element." );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->step(), "Failed to step into supported {$tag_name} element." );
+ $this->assertSame( $tag_name, $processor->get_tag(), "Misread {$tag_name} as a {$processor->get_tag()} element." );
</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">@@ -34,7 +34,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_single_tag_of_supported_elements() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_single_tag_of_supported_elements() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $supported_elements = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'A',
</span><span class="cx" style="display: block; padding: 0 10px"> 'ABBR',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -155,9 +155,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $html HTML string containing unsupported elements.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_fails_when_encountering_unsupported_tag( $html ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( $html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( $html );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->step(), "Should not have stepped into unsupported {$p->get_tag()} element." );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->step(), "Should not have stepped into unsupported {$processor->get_tag()} element." );
</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">@@ -165,7 +165,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_unsupported_elements() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_unsupported_elements() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $unsupported_elements = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'APPLET', // Deprecated.
</span><span class="cx" style="display: block; padding: 0 10px"> 'BASE',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -229,14 +229,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $html HTML containing unsupported markup.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_fails_when_encountering_unsupported_markup( $html, $description ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( $html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( $html );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- while ( $p->step() && null === $p->get_attribute( 'supported' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ while ( $processor->step() && null === $processor->get_attribute( 'supported' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</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">- $this->assertTrue( $p->get_attribute( 'supported' ), 'Did not find required supported element.' );
- $this->assertFalse( $p->step(), "Didn't properly reject unsupported markup: {$description}" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->get_attribute( 'supported' ), 'Did not find required supported element.' );
+ $this->assertFalse( $processor->step(), "Didn't properly reject unsupported markup: {$description}" );
</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">@@ -244,7 +244,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_unsupported_markup() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_unsupported_markup() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'A with formatting following unclosed A' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> '<a><strong>Click <a supported><big unsupported>Here</big></a></strong></a>',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -270,9 +270,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $n How many breadcrumb matches to scan through in order to find "target" element.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_finds_correct_tag_given_breadcrumbs( $html, $breadcrumbs, $n ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( $html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( $html );
</ins><span class="cx" style="display: block; padding: 0 10px">
</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">+ $processor->next_tag(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'breadcrumbs' => $breadcrumbs,
</span><span class="cx" style="display: block; padding: 0 10px"> 'match_offset' => $n,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -279,8 +279,8 @@
</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">- $this->assertNotNull( $p->get_tag(), 'Failed to find target node.' );
- $this->assertTrue( $p->get_attribute( 'target' ), "Found {$p->get_tag()} element didn't contain the necessary 'target' attribute." );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotNull( $processor->get_tag(), 'Failed to find target node.' );
+ $this->assertTrue( $processor->get_attribute( 'target' ), "Found {$processor->get_tag()} element didn't contain the necessary 'target' attribute." );
</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">@@ -295,14 +295,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $ignored_n Not used in this test but provided in the dataset for other tests.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_reports_correct_breadcrumbs_for_html( $html, $breadcrumbs, $ignored_n ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( $html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( $html );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- while ( $p->next_tag() && null === $p->get_attribute( 'target' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ while ( $processor->next_tag() && null === $processor->get_attribute( 'target' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</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">- $this->assertNotNull( $p->get_tag(), 'Failed to find the target node.' );
- $this->assertSame( $breadcrumbs, $p->get_breadcrumbs(), 'Found the wrong path from the root of the HTML document to the target node.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotNull( $processor->get_tag(), 'Failed to find the target node.' );
+ $this->assertSame( $breadcrumbs, $processor->get_breadcrumbs(), 'Found the wrong path from the root of the HTML document to the target node.' );
</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">@@ -310,7 +310,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_html_target_with_breadcrumbs() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_html_target_with_breadcrumbs() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Simple IMG tag' => array( '<img target>', array( 'HTML', 'BODY', 'IMG' ), 1 ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Two sibling IMG tags' => array( '<img><img target>', array( 'HTML', 'BODY', 'IMG' ), 2 ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -393,7 +393,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[].
</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 data_html_with_breadcrumbs_of_various_specificity() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_html_with_breadcrumbs_of_various_specificity() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> // Test with void elements.
</span><span class="cx" style="display: block; padding: 0 10px"> 'Inner IMG' => array( '<div><span><figure><img target></figure></span></div>', array( 'span', 'figure', 'img' ), true ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -433,38 +433,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_updated_html
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remains_stable_when_editing_attributes() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<div><button>First<button><b here>Second' );
- $p->next_tag( array( 'breadcrumbs' => array( 'BUTTON', 'B' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<div><button>First<button><b here>Second' );
+ $processor->next_tag( array( 'breadcrumbs' => array( 'BUTTON', 'B' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> array( 'HTML', 'BODY', 'DIV', 'BUTTON', 'B' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_breadcrumbs(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_breadcrumbs(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Found the wrong nested structure at the matched tag.'
</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">- $p->set_attribute( 'a-name', 'a-value' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->set_attribute( 'a-name', 'a-value' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'here' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'here' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Should have found the B tag but could not find expected "here" attribute.'
</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"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> array( 'HTML', 'BODY', 'DIV', 'BUTTON', 'B' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_breadcrumbs(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_breadcrumbs(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Found the wrong nested structure at the matched tag.'
</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">- $p->get_updated_html();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'here' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'here' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Should have stayed at the B tag but could not find expected "here" attribute.'
</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"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> array( 'HTML', 'BODY', 'DIV', 'BUTTON', 'B' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_breadcrumbs(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_breadcrumbs(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Found the wrong nested structure at the matched tag after updating attributes.'
</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">@@ -479,12 +479,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_can_modify_attributes_after_finding_tag() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<div><figure><img><figcaption>test</figcaption></figure>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<div><figure><img><figcaption>test</figcaption></figure>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( array( 'breadcrumbs' => array( 'figcaption' ) ) ), 'Unable to find given tag.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( array( 'breadcrumbs' => array( 'figcaption' ) ) ), 'Unable to find given 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">- $p->set_attribute( 'found-it', true );
- $this->assertSame( '<div><figure><img><figcaption found-it>test</figcaption></figure>', $p->get_updated_html() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->set_attribute( 'found-it', true );
+ $this->assertSame( '<div><figure><img><figcaption found-it>test</figcaption></figure>', $processor->get_updated_html() );
</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">@@ -497,11 +497,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Processor::next_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_can_query_an_element_by_tag_name() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<div><DIV><strong><img></strong></DIV>' );
- $p->next_tag( 'IMG' );
- $p->set_attribute( 'loading', 'lazy' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<div><DIV><strong><img></strong></DIV>' );
+ $processor->next_tag( 'IMG' );
+ $processor->set_attribute( 'loading', 'lazy' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '<div><DIV><strong><img loading="lazy"></strong></DIV>', $p->get_updated_html() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '<div><DIV><strong><img loading="lazy"></strong></DIV>', $processor->get_updated_html() );
</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">@@ -514,7 +514,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Processor::seek
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_can_seek_back_and_forth() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment(
</ins><span class="cx" style="display: block; padding: 0 10px"> <<<'HTML'
</span><span class="cx" style="display: block; padding: 0 10px"> <div>text<p one>more stuff<div><![CDATA[this is not real CDATA]]><p><!-- hi --><div two><p><div><p>three comes soon<div><p three>' );
</span><span class="cx" style="display: block; padding: 0 10px"> HTML
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -521,28 +521,28 @@
</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"> // Find first tag of interest.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- while ( $p->next_tag() && null === $p->get_attribute( 'one' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ while ( $processor->next_tag() && null === $processor->get_attribute( 'one' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->set_bookmark( 'first' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->set_bookmark( 'first' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Find second tag of interest.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- while ( $p->next_tag() && null === $p->get_attribute( 'two' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ while ( $processor->next_tag() && null === $processor->get_attribute( 'two' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->set_bookmark( 'second' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->set_bookmark( 'second' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Find third tag of interest.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- while ( $p->next_tag() && null === $p->get_attribute( 'three' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ while ( $processor->next_tag() && null === $processor->get_attribute( 'three' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->set_bookmark( 'third' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->set_bookmark( 'third' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Seek backwards.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'first' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'first' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Seek forwards. If the current token isn't also updated this could appear like a backwards seek.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'second' );
- $this->assertTrue( $p->get_attribute( 'two' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'second' );
+ $this->assertTrue( $processor->get_attribute( 'two' ) );
</ins><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="trunktestsphpunittestshtmlapiwpHtmlProcessorSemanticRulesphp"></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/html-api/wpHtmlProcessorSemanticRules.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php 2024-02-01 00:41:40 UTC (rev 57507)
+++ trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php 2024-02-01 01:00:56 UTC (rev 57508)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -79,7 +79,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[].
</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 data_article_container_group() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_article_container_group() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $group = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach (
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -122,19 +122,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 58961
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_in_body_skips_unexpected_button_closer() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<div>Test</button></div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<div>Test</button></div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->step();
- $this->assertSame( 'DIV', $p->get_tag(), 'Did not stop at initial DIV tag.' );
- $this->assertFalse( $p->is_tag_closer(), 'Did not find that initial DIV tag is an opener.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->step();
+ $this->assertSame( 'DIV', $processor->get_tag(), 'Did not stop at initial DIV tag.' );
+ $this->assertFalse( $processor->is_tag_closer(), 'Did not find that initial DIV tag is an opener.' );
</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"> * When encountering the BUTTON closing tag, there is no BUTTON in the stack of open elements.
</span><span class="cx" style="display: block; padding: 0 10px"> * It should be ignored as there's no BUTTON to close.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->step(), 'Found no further tags when it should have found the closing DIV' );
- $this->assertSame( 'DIV', $p->get_tag(), "Did not skip unexpected BUTTON; stopped at {$p->get_tag()}." );
- $this->assertTrue( $p->is_tag_closer(), 'Did not find that the terminal DIV tag is a closer.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->step(), 'Found no further tags when it should have found the closing DIV' );
+ $this->assertSame( 'DIV', $processor->get_tag(), "Did not skip unexpected BUTTON; stopped at {$processor->get_tag()}." );
+ $this->assertTrue( $processor->is_tag_closer(), 'Did not find that the terminal DIV tag is a closer.' );
</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">@@ -143,11 +143,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 58961
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_in_body_button_with_no_button_in_scope() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<div><p>Click the button <button one>here</button>!</p></div><button two>not here</button>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<div><p>Click the button <button one>here</button>!</p></div><button two>not here</button>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'BUTTON' ), 'Could not find expected first button.' );
- $this->assertTrue( $p->get_attribute( 'one' ), 'Failed to match expected attribute on first button.' );
- $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'P', 'BUTTON' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting for first button.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'BUTTON' ), 'Could not find expected first button.' );
+ $this->assertTrue( $processor->get_attribute( 'one' ), 'Failed to match expected attribute on first button.' );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'P', 'BUTTON' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting for first button.' );
</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's nothing special about this HTML construction, but it's important to verify that
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -154,9 +154,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * the HTML Processor can find a BUTTON under normal and normative scenarios, not just the
</span><span class="cx" style="display: block; padding: 0 10px"> * malformed and unexpected ones.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'BUTTON' ), 'Could not find expected second button.' );
- $this->assertTrue( $p->get_attribute( 'two' ), 'Failed to match expected attribute on second button.' );
- $this->assertSame( array( 'HTML', 'BODY', 'BUTTON' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting for second button.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'BUTTON' ), 'Could not find expected second button.' );
+ $this->assertTrue( $processor->get_attribute( 'two' ), 'Failed to match expected attribute on second button.' );
+ $this->assertSame( array( 'HTML', 'BODY', 'BUTTON' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting for second button.' );
</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">@@ -168,27 +168,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.4.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_in_body_button_with_button_in_scope_as_parent() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<div><p>Click the button <button one>almost<button two>here</button>!</p></div><button three>not here</button>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<div><p>Click the button <button one>almost<button two>here</button>!</p></div><button three>not here</button>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'BUTTON' ), 'Could not find expected first button.' );
- $this->assertTrue( $p->get_attribute( 'one' ), 'Failed to match expected attribute on first button.' );
- $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'P', 'BUTTON' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting for first button.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'BUTTON' ), 'Could not find expected first button.' );
+ $this->assertTrue( $processor->get_attribute( 'one' ), 'Failed to match expected attribute on first button.' );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'P', 'BUTTON' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting for first button.' );
</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"> * A naive parser might skip the second BUTTON because it's looking for the close of the first one,
</span><span class="cx" style="display: block; padding: 0 10px"> * or it may place it as a child of the first one, but it implicitly closes the open BUTTON.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'BUTTON' ), 'Could not find expected second button.' );
- $this->assertTrue( $p->get_attribute( 'two' ), 'Failed to match expected attribute on second button.' );
- $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'P', 'BUTTON' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting for second button.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'BUTTON' ), 'Could not find expected second button.' );
+ $this->assertTrue( $processor->get_attribute( 'two' ), 'Failed to match expected attribute on second button.' );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'P', 'BUTTON' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting for second button.' );
</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"> * This is another form of the test for the second button, but from a different side. The test is
</span><span class="cx" style="display: block; padding: 0 10px"> * looking for proper handling of the open and close sequence for the BUTTON tags.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'BUTTON' ), 'Could not find expected third button.' );
- $this->assertTrue( $p->get_attribute( 'three' ), 'Failed to match expected attribute on third button.' );
- $this->assertSame( array( 'HTML', 'BODY', 'BUTTON' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting for third button.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'BUTTON' ), 'Could not find expected third button.' );
+ $this->assertTrue( $processor->get_attribute( 'three' ), 'Failed to match expected attribute on third button.' );
+ $this->assertSame( array( 'HTML', 'BODY', 'BUTTON' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting for third button.' );
</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">@@ -201,12 +201,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.4.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_in_body_button_with_button_in_scope_as_ancestor() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<div><button one><p>Click the button <span><button two>here</button>!</span></p></div><button three>not here</button>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<div><button one><p>Click the button <span><button two>here</button>!</span></p></div><button three>not here</button>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // This button finds itself normally nesting inside the DIV.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'BUTTON' ), 'Could not find expected first button.' );
- $this->assertTrue( $p->get_attribute( 'one' ), 'Failed to match expected attribute on first button.' );
- $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'BUTTON' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting for first button.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'BUTTON' ), 'Could not find expected first button.' );
+ $this->assertTrue( $processor->get_attribute( 'one' ), 'Failed to match expected attribute on first button.' );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'BUTTON' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting for first button.' );
</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"> * Because the second button appears while a BUTTON is in scope, it generates implied end tags and closes
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -214,14 +214,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * of an unexpected closing SPAN tag because the SPAN was closed by the second BUTTON. This element finds
</span><span class="cx" style="display: block; padding: 0 10px"> * itself a child of the most-recent open element above the most-recent BUTTON, or the DIV.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'BUTTON' ), 'Could not find expected second button.' );
- $this->assertTrue( $p->get_attribute( 'two' ), 'Failed to match expected attribute on second button.' );
- $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'BUTTON' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting for second button.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'BUTTON' ), 'Could not find expected second button.' );
+ $this->assertTrue( $processor->get_attribute( 'two' ), 'Failed to match expected attribute on second button.' );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'BUTTON' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting for second button.' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // The third button is back to normal, because everything has been implicitly or explicitly closed by now.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'BUTTON' ), 'Could not find expected third button.' );
- $this->assertTrue( $p->get_attribute( 'three' ), 'Failed to match expected attribute on third button.' );
- $this->assertSame( array( 'HTML', 'BODY', 'BUTTON' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting for third button.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'BUTTON' ), 'Could not find expected third button.' );
+ $this->assertTrue( $processor->get_attribute( 'three' ), 'Failed to match expected attribute on third button.' );
+ $this->assertSame( array( 'HTML', 'BODY', 'BUTTON' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting for third button.' );
</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">@@ -274,7 +274,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[].
</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 data_heading_elements() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_heading_elements() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'H1' => array( 'H1' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'H2' => array( 'H2' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -328,7 +328,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_heading_combinations() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_heading_combinations() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $headings = array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $combinations = array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -355,15 +355,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.4.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_in_body_any_other_end_tag_with_unclosed_special_element() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<div><span><p></span><div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<div><span><p></span><div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag( 'P' );
- $this->assertSame( 'P', $p->get_tag(), "Expected to start test on P element but found {$p->get_tag()} instead." );
- $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'SPAN', 'P' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag( 'P' );
+ $this->assertSame( 'P', $processor->get_tag(), "Expected to start test on P element but found {$processor->get_tag()} instead." );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'SPAN', 'P' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting.' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag(), 'Failed to advance past P tag to expected DIV opener.' );
- $this->assertSame( 'DIV', $p->get_tag(), "Expected to find DIV element, but found {$p->get_tag()} instead." );
- $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'SPAN', 'DIV' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting: SPAN should still be open and DIV should be its child.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag(), 'Failed to advance past P tag to expected DIV opener.' );
+ $this->assertSame( 'DIV', $processor->get_tag(), "Expected to find DIV element, but found {$processor->get_tag()} instead." );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'SPAN', 'DIV' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting: SPAN should still be open and DIV should be its child.' );
</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">@@ -378,19 +378,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.4.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_in_body_any_other_end_tag_with_unclosed_non_special_element() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '<div><span><code></span><div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '<div><span><code></span><div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag( 'CODE' );
- $this->assertSame( 'CODE', $p->get_tag(), "Expected to start test on CODE element but found {$p->get_tag()} instead." );
- $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'SPAN', 'CODE' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag( 'CODE' );
+ $this->assertSame( 'CODE', $processor->get_tag(), "Expected to start test on CODE element but found {$processor->get_tag()} instead." );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'SPAN', 'CODE' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting.' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->step(), 'Failed to advance past CODE tag to expected SPAN closer.' );
- $this->assertTrue( $p->is_tag_closer(), 'Expected to find closing SPAN, but found opener instead.' );
- $this->assertSame( array( 'HTML', 'BODY', 'DIV' ), $p->get_breadcrumbs(), 'Failed to advance past CODE tag to expected DIV opener.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->step(), 'Failed to advance past CODE tag to expected SPAN closer.' );
+ $this->assertTrue( $processor->is_tag_closer(), 'Expected to find closing SPAN, but found opener instead.' );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV' ), $processor->get_breadcrumbs(), 'Failed to advance past CODE tag to expected DIV opener.' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag(), 'Failed to advance past SPAN closer to expected DIV opener.' );
- $this->assertSame( 'DIV', $p->get_tag(), "Expected to find DIV element, but found {$p->get_tag()} instead." );
- $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'DIV' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting: SPAN should be closed and DIV should be its sibling.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag(), 'Failed to advance past SPAN closer to expected DIV opener.' );
+ $this->assertSame( 'DIV', $processor->get_tag(), "Expected to find DIV element, but found {$processor->get_tag()} instead." );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'DIV' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting: SPAN should be closed and DIV should be its sibling.' );
</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">@@ -412,9 +412,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 60283
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_br_end_tag_unsupported() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( '</br>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( '</br>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->next_tag(), 'Found a BR tag that should not be handled.' );
- $this->assertSame( WP_HTML_Processor::ERROR_UNSUPPORTED, $p->get_last_error() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->next_tag(), 'Found a BR tag that should not be handled.' );
+ $this->assertSame( WP_HTML_Processor::ERROR_UNSUPPORTED, $processor->get_last_error() );
</ins><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="trunktestsphpunittestshtmlapiwpHtmlProcessorSemanticRulesHeadingElementsphp"></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/html-api/wpHtmlProcessorSemanticRulesHeadingElements.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRulesHeadingElements.php 2024-02-01 00:41:40 UTC (rev 57507)
+++ trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRulesHeadingElements.php 2024-02-01 01:00:56 UTC (rev 57508)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,7 +53,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[].
</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 data_heading_elements() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_heading_elements() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'H1' => array( 'H1' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'H2' => array( 'H2' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -109,7 +109,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_heading_combinations() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_heading_combinations() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $headings = array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $combinations = array();
</span></span></pre></div>
<a id="trunktestsphpunittestshtmlapiwpHtmlSupportRequiredHtmlProcessorphp"></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/html-api/wpHtmlSupportRequiredHtmlProcessor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/html-api/wpHtmlSupportRequiredHtmlProcessor.php 2024-02-01 00:41:40 UTC (rev 57507)
+++ trunk/tests/phpunit/tests/html-api/wpHtmlSupportRequiredHtmlProcessor.php 2024-02-01 01:00:56 UTC (rev 57508)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,9 +42,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $tag_name the HTML Processor should abort when encountering this tag, e.g. "BUTTON".
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private function ensure_support_is_added_everywhere( $tag_name ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( "<$tag_name>" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( "<$tag_name>" );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->step(), "Must support terminating elements in specific scope check before adding support for the {$tag_name} element." );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->step(), "Must support terminating elements in specific scope check before adding support for the {$tag_name} element." );
</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="trunktestsphpunittestshtmlapiwpHtmlSupportRequiredOpenElementsphp"></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/html-api/wpHtmlSupportRequiredOpenElements.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php 2024-02-01 00:41:40 UTC (rev 57507)
+++ trunk/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php 2024-02-01 01:00:56 UTC (rev 57508)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,9 +44,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $tag_name the HTML Processor should abort when encountering this tag, e.g. "BUTTON".
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private function ensure_support_is_added_everywhere( $tag_name ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = WP_HTML_Processor::create_fragment( "<$tag_name>" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = WP_HTML_Processor::create_fragment( "<$tag_name>" );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->step(), "Must support terminating elements in specific scope check before adding support for the {$tag_name} element." );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->step(), "Must support terminating elements in specific scope check before adding support for the {$tag_name} element." );
</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="trunktestsphpunittestshtmlapiwpHtmlTagProcessorbookmarkphp"></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/html-api/wpHtmlTagProcessor-bookmark.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php 2024-02-01 00:41:40 UTC (rev 57507)
+++ trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php 2024-02-01 01:00:56 UTC (rev 57508)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -19,12 +19,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_bookmark
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_bookmark() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
- $p->next_tag( 'li' );
- $this->assertTrue( $p->set_bookmark( 'first li' ), 'Could not allocate a "first li" bookmark' );
- $p->next_tag( 'li' );
- $this->assertTrue( $p->set_bookmark( 'second li' ), 'Could not allocate a "second li" bookmark' );
- $this->assertTrue( $p->set_bookmark( 'first li' ), 'Could not move the "first li" bookmark' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
+ $processor->next_tag( 'li' );
+ $this->assertTrue( $processor->set_bookmark( 'first li' ), 'Could not allocate a "first li" bookmark' );
+ $processor->next_tag( 'li' );
+ $this->assertTrue( $processor->set_bookmark( 'second li' ), 'Could not allocate a "second li" bookmark' );
+ $this->assertTrue( $processor->set_bookmark( 'first li' ), 'Could not move the "first li" bookmark' );
</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">@@ -33,11 +33,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::release_bookmark
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_release_bookmark() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
- $p->next_tag( 'li' );
- $this->assertFalse( $p->release_bookmark( 'first li' ), 'Released a non-existing bookmark' );
- $p->set_bookmark( 'first li' );
- $this->assertTrue( $p->release_bookmark( 'first li' ), 'Could not release a bookmark' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
+ $processor->next_tag( 'li' );
+ $this->assertFalse( $processor->release_bookmark( 'first li' ), 'Released a non-existing bookmark' );
+ $processor->set_bookmark( 'first li' );
+ $this->assertTrue( $processor->release_bookmark( 'first li' ), 'Could not release a bookmark' );
</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">@@ -46,8 +46,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::has_bookmark
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_bookmark_returns_false_if_bookmark_does_not_exist() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>Test</div>' );
- $this->assertFalse( $p->has_bookmark( 'my-bookmark' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>Test</div>' );
+ $this->assertFalse( $processor->has_bookmark( 'my-bookmark' ) );
</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">@@ -56,10 +56,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::has_bookmark
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_bookmark_returns_true_if_bookmark_exists() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>Test</div>' );
- $p->next_tag();
- $p->set_bookmark( 'my-bookmark' );
- $this->assertTrue( $p->has_bookmark( 'my-bookmark' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>Test</div>' );
+ $processor->next_tag();
+ $processor->set_bookmark( 'my-bookmark' );
+ $this->assertTrue( $processor->has_bookmark( 'my-bookmark' ) );
</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">@@ -68,11 +68,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::has_bookmark
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_bookmark_returns_false_if_bookmark_has_been_released() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>Test</div>' );
- $p->next_tag();
- $p->set_bookmark( 'my-bookmark' );
- $p->release_bookmark( 'my-bookmark' );
- $this->assertFalse( $p->has_bookmark( 'my-bookmark' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>Test</div>' );
+ $processor->next_tag();
+ $processor->set_bookmark( 'my-bookmark' );
+ $processor->release_bookmark( 'my-bookmark' );
+ $this->assertFalse( $processor->has_bookmark( 'my-bookmark' ) );
</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">@@ -81,19 +81,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::seek
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_seek() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
- $p->next_tag( 'li' );
- $p->set_bookmark( 'first li' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
+ $processor->next_tag( 'li' );
+ $processor->set_bookmark( 'first li' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag( 'li' );
- $p->set_attribute( 'foo-2', 'bar-2' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag( 'li' );
+ $processor->set_attribute( 'foo-2', 'bar-2' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'first li' );
- $p->set_attribute( 'foo-1', 'bar-1' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'first li' );
+ $processor->set_attribute( 'foo-1', 'bar-1' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<ul><li foo-1="bar-1">One</li><li foo-2="bar-2">Two</li><li>Three</li></ul>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not seek to the intended bookmark locations'
</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">@@ -104,18 +104,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::seek
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_seeks_to_tag_closer_bookmark() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>First</div><span>Second</span>' );
- $p->next_tag( array( 'tag_closers' => 'visit' ) );
- $p->set_bookmark( 'first' );
- $p->next_tag( array( 'tag_closers' => 'visit' ) );
- $p->set_bookmark( 'second' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>First</div><span>Second</span>' );
+ $processor->next_tag( array( 'tag_closers' => 'visit' ) );
+ $processor->set_bookmark( 'first' );
+ $processor->next_tag( array( 'tag_closers' => 'visit' ) );
+ $processor->set_bookmark( 'second' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'first' );
- $p->seek( 'second' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'first' );
+ $processor->seek( 'second' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'DIV',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_tag(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_tag(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not seek to the intended bookmark location'
</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">@@ -159,24 +159,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_bookmark
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_removing_long_attributes_doesnt_break_seek() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $input = <<<HTML
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $input = <<<HTML
</ins><span class="cx" style="display: block; padding: 0 10px"> <button twenty_one_characters 7_chars></button><button></button>
</span><span class="cx" style="display: block; padding: 0 10px"> HTML;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $input );
- $p->next_tag( 'button' );
- $p->set_bookmark( 'first' );
- $p->next_tag( 'button' );
- $p->set_bookmark( 'second' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $input );
+ $processor->next_tag( 'button' );
+ $processor->set_bookmark( 'first' );
+ $processor->next_tag( 'button' );
+ $processor->set_bookmark( 'second' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'first' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'first' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Seek() to the first button has failed'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->remove_attribute( 'twenty_one_characters' );
- $p->remove_attribute( '7_chars' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->remove_attribute( 'twenty_one_characters' );
+ $processor->remove_attribute( '7_chars' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'second' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'second' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Seek() to the second button has failed'
</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">@@ -232,61 +232,61 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> HTML;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $input );
- $p->next_tag( 'div' );
- $p->next_tag( 'div' );
- $p->next_tag( 'div' );
- $p->set_bookmark( 'first div' );
- $p->next_tag( 'button' );
- $p->set_bookmark( 'first button' );
- $p->next_tag( 'button' );
- $p->set_bookmark( 'second button' );
- $p->next_tag( 'button' );
- $p->set_bookmark( 'third button' );
- $p->next_tag( 'button' );
- $p->set_bookmark( 'fourth button' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $input );
+ $processor->next_tag( 'div' );
+ $processor->next_tag( 'div' );
+ $processor->next_tag( 'div' );
+ $processor->set_bookmark( 'first div' );
+ $processor->next_tag( 'button' );
+ $processor->set_bookmark( 'first button' );
+ $processor->next_tag( 'button' );
+ $processor->set_bookmark( 'second button' );
+ $processor->next_tag( 'button' );
+ $processor->set_bookmark( 'third button' );
+ $processor->next_tag( 'button' );
+ $processor->set_bookmark( 'fourth button' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'first button' );
- $p->set_attribute( 'type', 'submit' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'first button' );
+ $processor->set_attribute( 'type', 'submit' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'third button' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'third button' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Seek() to the third button failed'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->remove_attribute( 'class' );
- $p->remove_attribute( 'type' );
- $p->remove_attribute( 'aria-expanded' );
- $p->set_attribute( 'id', 'rebase-and-merge' );
- $p->remove_attribute( 'data-details-container' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->remove_attribute( 'class' );
+ $processor->remove_attribute( 'type' );
+ $processor->remove_attribute( 'aria-expanded' );
+ $processor->set_attribute( 'id', 'rebase-and-merge' );
+ $processor->remove_attribute( 'data-details-container' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'first div' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'first div' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Seek() to the first div failed'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->set_attribute( 'checked', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->set_attribute( 'checked', false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'fourth button' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'fourth button' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Seek() to the fourth button failed'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->set_attribute( 'id', 'last-button' );
- $p->remove_attribute( 'class' );
- $p->remove_attribute( 'type' );
- $p->remove_attribute( 'checked' );
- $p->remove_attribute( 'aria-label' );
- $p->remove_attribute( 'disabled' );
- $p->remove_attribute( 'data-view-component' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->set_attribute( 'id', 'last-button' );
+ $processor->remove_attribute( 'class' );
+ $processor->remove_attribute( 'type' );
+ $processor->remove_attribute( 'checked' );
+ $processor->remove_attribute( 'aria-label' );
+ $processor->remove_attribute( 'disabled' );
+ $processor->remove_attribute( 'data-view-component' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'second button' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'second button' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Seek() to the second button failed'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->remove_attribute( 'type' );
- $p->set_attribute( 'class', 'hx_create-pr-button' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->remove_attribute( 'type' );
+ $processor->set_attribute( 'class', 'hx_create-pr-button' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_output,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Performing several attribute updates on different tags does not produce the expected HTML snippet'
</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">@@ -297,18 +297,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::seek
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_updates_bookmark_for_additions_after_both_sides() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>First</div><div>Second</div>' );
- $p->next_tag();
- $p->set_bookmark( 'first' );
- $p->next_tag();
- $p->add_class( 'second' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>First</div><div>Second</div>' );
+ $processor->next_tag();
+ $processor->set_bookmark( 'first' );
+ $processor->next_tag();
+ $processor->add_class( 'second' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'first' );
- $p->add_class( 'first' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'first' );
+ $processor->add_class( 'first' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="first">First</div><div class="second">Second</div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'The bookmark was updated incorrectly in response to HTML markup updates'
</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">@@ -319,21 +319,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::seek
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_updates_bookmark_for_additions_before_both_sides() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>First</div><div>Second</div>' );
- $p->next_tag();
- $p->set_bookmark( 'first' );
- $p->next_tag();
- $p->set_bookmark( 'second' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>First</div><div>Second</div>' );
+ $processor->next_tag();
+ $processor->set_bookmark( 'first' );
+ $processor->next_tag();
+ $processor->set_bookmark( 'second' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'first' );
- $p->add_class( 'first' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'first' );
+ $processor->add_class( 'first' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'second' );
- $p->add_class( 'second' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'second' );
+ $processor->add_class( 'second' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="first">First</div><div class="second">Second</div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'The bookmark was updated incorrectly in response to HTML markup updates'
</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">@@ -344,14 +344,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::seek
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_updates_bookmark_for_deletions_after_both_sides() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>First</div><div disabled>Second</div>' );
- $p->next_tag();
- $p->set_bookmark( 'first' );
- $p->next_tag();
- $p->remove_attribute( 'disabled' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>First</div><div disabled>Second</div>' );
+ $processor->next_tag();
+ $processor->set_bookmark( 'first' );
+ $processor->next_tag();
+ $processor->remove_attribute( 'disabled' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'first' );
- $p->set_attribute( 'untouched', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'first' );
+ $processor->set_attribute( 'untouched', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -363,7 +363,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * is not required.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> '<div untouched>First</div><div >Second</div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'The bookmark was incorrectly in response to HTML markup updates'
</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">@@ -374,17 +374,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::seek
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_updates_bookmark_for_deletions_before_both_sides() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div disabled>First</div><div>Second</div>' );
- $p->next_tag();
- $p->set_bookmark( 'first' );
- $p->next_tag();
- $p->set_bookmark( 'second' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div disabled>First</div><div>Second</div>' );
+ $processor->next_tag();
+ $processor->set_bookmark( 'first' );
+ $processor->next_tag();
+ $processor->set_bookmark( 'second' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'first' );
- $p->remove_attribute( 'disabled' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'first' );
+ $processor->remove_attribute( 'disabled' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->seek( 'second' );
- $p->set_attribute( 'safe', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->seek( 'second' );
+ $processor->set_attribute( 'safe', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -396,7 +396,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * is not required.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> '<div >First</div><div safe>Second</div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'The bookmark was updated incorrectly in response to HTML markup updates'
</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">@@ -407,15 +407,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_bookmark
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_limits_the_number_of_bookmarks() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
- $p->next_tag( 'li' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
+ $processor->next_tag( 'li' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> for ( $i = 0; $i < WP_HTML_Tag_Processor::MAX_BOOKMARKS; $i++ ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->set_bookmark( "bookmark $i" ), "Could not allocate the bookmark #$i" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->set_bookmark( "bookmark $i" ), "Could not allocate the bookmark #$i" );
</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"> $this->setExpectedIncorrectUsage( 'WP_HTML_Tag_Processor::set_bookmark' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->set_bookmark( 'final bookmark' ), "Allocated $i bookmarks, which is one above the limit" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->set_bookmark( 'final bookmark' ), "Allocated $i bookmarks, which is one above the limit" );
</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">@@ -424,15 +424,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::seek
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_limits_the_number_of_seek_calls() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
- $p->next_tag( 'li' );
- $p->set_bookmark( 'bookmark' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
+ $processor->next_tag( 'li' );
+ $processor->set_bookmark( 'bookmark' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> for ( $i = 0; $i < WP_HTML_Tag_Processor::MAX_SEEK_OPS; $i++ ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->seek( 'bookmark' ), 'Could not seek to the "bookmark"' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->seek( 'bookmark' ), 'Could not seek to the "bookmark"' );
</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"> $this->setExpectedIncorrectUsage( 'WP_HTML_Tag_Processor::seek' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->seek( 'bookmark' ), "$i-th seek() to the bookmark succeeded, even though it should exceed the allowed limit" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->seek( 'bookmark' ), "$i-th seek() to the bookmark succeeded, even though it should exceed the allowed limit" );
</ins><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="trunktestsphpunittestshtmlapiwpHtmlTagProcessortokenscanningphp"></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/html-api/wpHtmlTagProcessor-token-scanning.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php 2024-02-01 00:41:40 UTC (rev 57507)
+++ trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php 2024-02-01 01:00:56 UTC (rev 57508)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -295,7 +295,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[].
</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 data_rawtext_elements() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_rawtext_elements() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'IFRAME' => array( 'IFRAME' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'NOEMBED' => array( 'NOEMBED' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -580,7 +580,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[].
</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 data_common_comments() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_common_comments() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Shortest comment' => array( '<!-->', '' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Short comment' => array( '<!--->', '' ),
</span></span></pre></div>
<a id="trunktestsphpunittestshtmlapiwpHtmlTagProcessorphp"></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/html-api/wpHtmlTagProcessor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php 2024-02-01 00:41:40 UTC (rev 57507)
+++ trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php 2024-02-01 01:00:56 UTC (rev 57508)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -22,9 +22,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_tag_returns_null_before_finding_tags() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNull( $p->get_tag(), 'Calling get_tag() without selecting a tag did not return null' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNull( $processor->get_tag(), 'Calling get_tag() without selecting a tag did not return null' );
</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">@@ -33,10 +33,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_tag_returns_null_when_not_in_open_tag() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->next_tag( 'p' ), 'Querying a non-existing tag did not return false' );
- $this->assertNull( $p->get_tag(), 'Accessing a non-existing tag did not return null' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->next_tag( 'p' ), 'Querying a non-existing tag did not return false' );
+ $this->assertNull( $processor->get_tag(), 'Accessing a non-existing tag did not return null' );
</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">@@ -45,10 +45,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_tag_returns_open_tag_name() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'div' ), 'Querying an existing tag did not return true' );
- $this->assertSame( 'DIV', $p->get_tag(), 'Accessing an existing tag name did not return "div"' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'div' ), 'Querying an existing tag did not return true' );
+ $this->assertSame( 'DIV', $processor->get_tag(), 'Accessing an existing tag name did not return "div"' );
</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">@@ -62,13 +62,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $flag_is_set Whether the input HTML's first tag contains the self-closing flag.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_self_closing_flag_matches_input_html( $html, $flag_is_set ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $html );
- $p->next_tag( array( 'tag_closers' => 'visit' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $html );
+ $processor->next_tag( array( 'tag_closers' => 'visit' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $flag_is_set ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->has_self_closing_flag(), 'Did not find the self-closing tag when it was present.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->has_self_closing_flag(), 'Did not find the self-closing tag when it was present.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->has_self_closing_flag(), 'Found the self-closing tag when it was absent.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->has_self_closing_flag(), 'Found the self-closing tag when it was absent.' );
</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">@@ -77,7 +77,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_has_self_closing_flag() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_has_self_closing_flag() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> // These should not have a self-closer, and will leave an element un-closed if it's assumed they are self-closing.
</span><span class="cx" style="display: block; padding: 0 10px"> 'Self-closing flag on non-void HTML element' => array( '<div />', true ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -107,9 +107,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_returns_null_before_finding_tags() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNull( $p->get_attribute( 'class' ), 'Accessing an attribute without selecting a tag did not return null' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNull( $processor->get_attribute( 'class' ), 'Accessing an attribute without selecting a tag did not return null' );
</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">@@ -118,10 +118,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_returns_null_when_not_in_open_tag() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->next_tag( 'p' ), 'Querying a non-existing tag did not return false' );
- $this->assertNull( $p->get_attribute( 'class' ), 'Accessing an attribute of a non-existing tag did not return null' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->next_tag( 'p' ), 'Querying a non-existing tag did not return false' );
+ $this->assertNull( $processor->get_attribute( 'class' ), 'Accessing an attribute of a non-existing tag did not return null' );
</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">@@ -130,11 +130,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_returns_null_when_in_closing_tag() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'div' ), 'Querying an existing tag did not return true' );
- $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), 'Querying an existing closing tag did not return true' );
- $this->assertNull( $p->get_attribute( 'class' ), 'Accessing an attribute of a closing tag did not return null' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'div' ), 'Querying an existing tag did not return true' );
+ $this->assertTrue( $processor->next_tag( array( 'tag_closers' => 'visit' ) ), 'Querying an existing closing tag did not return true' );
+ $this->assertNull( $processor->get_attribute( 'class' ), 'Accessing an attribute of a closing tag did not return null' );
</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">@@ -143,10 +143,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_returns_null_when_attribute_missing() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'div' ), 'Querying an existing tag did not return true' );
- $this->assertNull( $p->get_attribute( 'test-id' ), 'Accessing a non-existing attribute did not return null' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'div' ), 'Querying an existing tag did not return true' );
+ $this->assertNull( $processor->get_attribute( 'test-id' ), 'Accessing a non-existing attribute did not return null' );
</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">@@ -155,10 +155,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_returns_attribute_value() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'div' ), 'Querying an existing tag did not return true' );
- $this->assertSame( 'test', $p->get_attribute( 'class' ), 'Accessing a class="test" attribute value did not return "test"' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'div' ), 'Querying an existing tag did not return true' );
+ $this->assertSame( 'test', $processor->get_attribute( 'class' ), 'Accessing a class="test" attribute value did not return "test"' );
</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">@@ -167,10 +167,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_returns_true_for_boolean_attribute() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div enabled class="test">Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div enabled class="test">Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( array( 'class_name' => 'test' ) ), 'Querying an existing tag did not return true' );
- $this->assertTrue( $p->get_attribute( 'enabled' ), 'Accessing a boolean "enabled" attribute value did not return true' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( array( 'class_name' => 'test' ) ), 'Querying an existing tag did not return true' );
+ $this->assertTrue( $processor->get_attribute( 'enabled' ), 'Accessing a boolean "enabled" attribute value did not 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="lines" style="display: block; padding: 0 10px; color: #888">@@ -179,12 +179,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_returns_string_for_truthy_attributes() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div enabled=enabled checked=1 hidden="true" class="test">Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div enabled=enabled checked=1 hidden="true" class="test">Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag(), 'Querying an existing tag did not return true' );
- $this->assertSame( 'enabled', $p->get_attribute( 'enabled' ), 'Accessing a boolean "enabled" attribute value did not return true' );
- $this->assertSame( '1', $p->get_attribute( 'checked' ), 'Accessing a checked=1 attribute value did not return "1"' );
- $this->assertSame( 'true', $p->get_attribute( 'hidden' ), 'Accessing a hidden="true" attribute value did not return "true"' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag(), 'Querying an existing tag did not return true' );
+ $this->assertSame( 'enabled', $processor->get_attribute( 'enabled' ), 'Accessing a boolean "enabled" attribute value did not return true' );
+ $this->assertSame( '1', $processor->get_attribute( 'checked' ), 'Accessing a checked=1 attribute value did not return "1"' );
+ $this->assertSame( 'true', $processor->get_attribute( 'hidden' ), 'Accessing a hidden="true" attribute value did not 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="lines" style="display: block; padding: 0 10px; color: #888">@@ -193,10 +193,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_decodes_html_character_references() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div id="the "grande" is < 32oz†"></div>' );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div id="the "grande" is < 32oz†"></div>' );
+ $processor->next_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">- $this->assertSame( 'the "grande" is < 32oz†', $p->get_attribute( 'id' ), 'HTML Attribute value was returned without decoding character references' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 'the "grande" is < 32oz†', $processor->get_attribute( 'id' ), 'HTML Attribute value was returned without decoding character references' );
</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">@@ -205,14 +205,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_attributes_parser_treats_slash_as_attribute_separator() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div a/b/c/d/e="test">Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div a/b/c/d/e="test">Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag(), 'Querying an existing tag did not return true' );
- $this->assertTrue( $p->get_attribute( 'a' ), 'Accessing an existing attribute did not return true' );
- $this->assertTrue( $p->get_attribute( 'b' ), 'Accessing an existing attribute did not return true' );
- $this->assertTrue( $p->get_attribute( 'c' ), 'Accessing an existing attribute did not return true' );
- $this->assertTrue( $p->get_attribute( 'd' ), 'Accessing an existing attribute did not return true' );
- $this->assertSame( 'test', $p->get_attribute( 'e' ), 'Accessing an existing e="test" did not return "test"' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag(), 'Querying an existing tag did not return true' );
+ $this->assertTrue( $processor->get_attribute( 'a' ), 'Accessing an existing attribute did not return true' );
+ $this->assertTrue( $processor->get_attribute( 'b' ), 'Accessing an existing attribute did not return true' );
+ $this->assertTrue( $processor->get_attribute( 'c' ), 'Accessing an existing attribute did not return true' );
+ $this->assertTrue( $processor->get_attribute( 'd' ), 'Accessing an existing attribute did not return true' );
+ $this->assertSame( 'test', $processor->get_attribute( 'e' ), 'Accessing an existing e="test" did not return "test"' );
</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">@@ -225,12 +225,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $attribute_name Name of data-enabled attribute with case variations.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_is_case_insensitive_for_attributes_with_values( $attribute_name ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div DATA-enabled="true">Test</div>' );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div DATA-enabled="true">Test</div>' );
+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'true',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( $attribute_name ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( $attribute_name ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Accessing an attribute by a differently-cased name did not return its value'
</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">@@ -245,11 +245,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $attribute_name Name of data-enabled attribute with case variations.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_attributes_parser_is_case_insensitive_for_attributes_without_values( $attribute_name ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div DATA-enabled>Test</div>' );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div DATA-enabled>Test</div>' );
+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( $attribute_name ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( $attribute_name ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Accessing an attribute by a differently-cased name did not return its value'
</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">@@ -259,7 +259,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[].
</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 data_attribute_name_case_variants() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_attribute_name_case_variants() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> array( 'DATA-enabled' ),
</span><span class="cx" style="display: block; padding: 0 10px"> array( 'data-enabled' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -274,11 +274,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_attribute_is_case_insensitive() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div DATA-enabled="true">Test</div>' );
- $p->next_tag();
- $p->remove_attribute( 'data-enabled' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div DATA-enabled="true">Test</div>' );
+ $processor->next_tag();
+ $processor->remove_attribute( 'data-enabled' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '<div >Test</div>', $p->get_updated_html(), 'A case-insensitive remove_attribute call did not remove the attribute' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '<div >Test</div>', $processor->get_updated_html(), 'A case-insensitive remove_attribute call did not remove the attribute' );
</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">@@ -287,11 +287,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_attribute_is_case_insensitive() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div DATA-enabled="true">Test</div>' );
- $p->next_tag();
- $p->set_attribute( 'data-enabled', 'abc' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div DATA-enabled="true">Test</div>' );
+ $processor->next_tag();
+ $processor->set_attribute( 'data-enabled', 'abc' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '<div data-enabled="abc">Test</div>', $p->get_updated_html(), 'A case-insensitive set_attribute call did not update the existing attribute' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '<div data-enabled="abc">Test</div>', $processor->get_updated_html(), 'A case-insensitive set_attribute call did not update the existing attribute' );
</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">@@ -300,9 +300,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute_names_with_prefix
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_names_with_prefix_returns_null_before_finding_tags() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div data-foo="bar">Test</div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div data-foo="bar">Test</div>' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute_names_with_prefix( 'data-' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute_names_with_prefix( 'data-' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Accessing attributes by their prefix did not return null when no tag was selected'
</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">@@ -313,9 +313,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute_names_with_prefix
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_names_with_prefix_returns_null_when_not_in_open_tag() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div data-foo="bar">Test</div>' );
- $p->next_tag( 'p' );
- $this->assertNull( $p->get_attribute_names_with_prefix( 'data-' ), 'Accessing attributes of a non-existing tag did not return null' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div data-foo="bar">Test</div>' );
+ $processor->next_tag( 'p' );
+ $this->assertNull( $processor->get_attribute_names_with_prefix( 'data-' ), 'Accessing attributes of a non-existing tag did not return null' );
</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">@@ -324,11 +324,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute_names_with_prefix
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_names_with_prefix_returns_null_when_in_closing_tag() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div data-foo="bar">Test</div>' );
- $p->next_tag( 'div' );
- $p->next_tag( array( 'tag_closers' => 'visit' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div data-foo="bar">Test</div>' );
+ $processor->next_tag( 'div' );
+ $processor->next_tag( array( 'tag_closers' => 'visit' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNull( $p->get_attribute_names_with_prefix( 'data-' ), 'Accessing attributes of a closing tag did not return null' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNull( $processor->get_attribute_names_with_prefix( 'data-' ), 'Accessing attributes of a closing tag did not return null' );
</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">@@ -337,10 +337,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute_names_with_prefix
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_names_with_prefix_returns_empty_array_when_no_attributes_present() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>Test</div>' );
- $p->next_tag( 'div' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>Test</div>' );
+ $processor->next_tag( 'div' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array(), $p->get_attribute_names_with_prefix( 'data-' ), 'Accessing the attributes on a tag without any did not return an empty array' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array(), $processor->get_attribute_names_with_prefix( 'data-' ), 'Accessing the attributes on a tag without any did not return an empty 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">@@ -349,12 +349,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute_names_with_prefix
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_names_with_prefix_returns_matching_attribute_names_in_lowercase() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div DATA-enabled class="test" data-test-ID="14">Test</div>' );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div DATA-enabled class="test" data-test-ID="14">Test</div>' );
+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> array( 'data-enabled', 'data-test-id' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute_names_with_prefix( 'data-' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute_names_with_prefix( 'data-' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Accessing attributes by their prefix did not return their lowercase names'
</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">@@ -365,18 +365,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute_names_with_prefix
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_names_with_prefix_returns_attribute_added_by_set_attribute() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div data-foo="bar">Test</div>' );
- $p->next_tag();
- $p->set_attribute( 'data-test-id', '14' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div data-foo="bar">Test</div>' );
+ $processor->next_tag();
+ $processor->set_attribute( 'data-test-id', '14' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div data-test-id="14" data-foo="bar">Test</div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Updated HTML doesn't include attribute added via set_attribute"
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> array( 'data-test-id', 'data-foo' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute_names_with_prefix( 'data-' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute_names_with_prefix( 'data-' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Accessing attribute names doesn't find attribute added via set_attribute"
</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">@@ -387,17 +387,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::__toString
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_to_string_returns_updated_html() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<hr id="remove" /><div enabled class="test">Test</div><span id="span-id"></span>' );
- $p->next_tag();
- $p->remove_attribute( 'id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<hr id="remove" /><div enabled class="test">Test</div><span id="span-id"></span>' );
+ $processor->next_tag();
+ $processor->remove_attribute( 'id' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag();
- $p->set_attribute( 'id', 'div-id-1' );
- $p->add_class( 'new_class_1' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag();
+ $processor->set_attribute( 'id', 'div-id-1' );
+ $processor->add_class( 'new_class_1' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
- (string) $p,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
+ (string) $processor,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_updated_html() returned a different value than __toString()'
</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">@@ -408,35 +408,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_updated_html
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_updated_html_applies_the_updates_so_far_and_keeps_the_processor_on_the_current_tag() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<hr id="remove" /><div enabled class="test">Test</div><span id="span-id"></span>' );
- $p->next_tag();
- $p->remove_attribute( 'id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<hr id="remove" /><div enabled class="test">Test</div><span id="span-id"></span>' );
+ $processor->next_tag();
+ $processor->remove_attribute( 'id' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag();
- $p->set_attribute( 'id', 'div-id-1' );
- $p->add_class( 'new_class_1' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag();
+ $processor->set_attribute( 'id', 'div-id-1' );
+ $processor->add_class( 'new_class_1' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<hr /><div id="div-id-1" enabled class="test new_class_1">Test</div><span id="span-id"></span>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Calling get_updated_html after updating the attributes of the second tag returned different HTML than expected'
</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">- $p->set_attribute( 'id', 'div-id-2' );
- $p->add_class( 'new_class_2' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->set_attribute( 'id', 'div-id-2' );
+ $processor->add_class( 'new_class_2' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<hr /><div id="div-id-2" enabled class="test new_class_1 new_class_2">Test</div><span id="span-id"></span>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Calling get_updated_html after updating the attributes of the second tag for the second time returned different HTML than expected'
</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">- $p->next_tag();
- $p->remove_attribute( 'id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag();
+ $processor->remove_attribute( 'id' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<hr /><div id="div-id-2" enabled class="test new_class_1 new_class_2">Test</div><span ></span>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Calling get_updated_html after removing the id attribute of the third tag returned different HTML than expected'
</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">@@ -447,11 +447,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_updated_html
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_updated_html_without_updating_any_attributes_returns_the_original_html() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> self::HTML_SIMPLE,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Casting WP_HTML_Tag_Processor to a string without performing any updates did not return the initial HTML snippet'
</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">@@ -463,17 +463,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 58160
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_updated_html_applies_updates_to_content_after_seeking_to_before_parsed_bytes() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div><img hidden></div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div><img hidden></div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag();
- $p->set_attribute( 'wonky', true );
- $p->next_tag();
- $p->set_bookmark( 'here' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag();
+ $processor->set_attribute( 'wonky', true );
+ $processor->next_tag();
+ $processor->set_bookmark( 'here' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag( array( 'tag_closers' => 'visit' ) );
- $p->seek( 'here' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag( array( 'tag_closers' => 'visit' ) );
+ $processor->seek( 'here' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '<div wonky><img hidden></div>', $p->get_updated_html() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '<div wonky><img hidden></div>', $processor->get_updated_html() );
</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">@@ -482,9 +482,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::next_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_next_tag_with_no_arguments_should_find_the_next_existing_tag() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag(), 'Querying an existing tag did not return true' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag(), 'Querying an existing tag did not 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="lines" style="display: block; padding: 0 10px; color: #888">@@ -493,9 +493,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::next_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_next_tag_should_return_false_for_a_non_existing_tag() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->next_tag( 'p' ), 'Querying a non-existing tag did not return false' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->next_tag( 'p' ), 'Querying a non-existing tag did not 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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -504,9 +504,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::next_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_next_tag_matches_decoded_class_names() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div class="<egg>">' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div class="<egg>">' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( array( 'class_name' => '<egg>' ) ), 'Failed to find tag with HTML-encoded class name.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( array( 'class_name' => '<egg>' ) ), 'Failed to find tag with HTML-encoded class name.' );
</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">@@ -517,13 +517,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::is_tag_closer
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_next_tag_should_stop_on_closers_only_when_requested() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div><img /></div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div><img /></div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( array( 'tag_name' => 'div' ) ), 'Did not find desired tag opener' );
- $this->assertFalse( $p->next_tag( array( 'tag_name' => 'div' ) ), 'Visited an unwanted tag, a tag closer' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( array( 'tag_name' => 'div' ) ), 'Did not find desired tag opener' );
+ $this->assertFalse( $processor->next_tag( array( 'tag_name' => 'div' ) ), 'Visited an unwanted tag, a tag closer' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div><img /></div>' );
- $p->next_tag(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div><img /></div>' );
+ $processor->next_tag(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_name' => 'div',
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_closers' => 'visit',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -530,9 +530,9 @@
</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">- $this->assertFalse( $p->is_tag_closer(), 'Indicated a tag opener is a tag closer' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->is_tag_closer(), 'Indicated a tag opener is a tag closer' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</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">+ $processor->next_tag(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_name' => 'div',
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_closers' => 'visit',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -540,11 +540,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Did not stop at desired tag closer'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->is_tag_closer(), 'Indicated a tag closer is a tag opener' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->is_tag_closer(), 'Indicated a tag closer is a tag opener' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>' );
- $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), "Did not find a tag opener when tag_closers was set to 'visit'" );
- $this->assertFalse( $p->next_tag( array( 'tag_closers' => 'visit' ) ), "Found a closer where there wasn't one" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>' );
+ $this->assertTrue( $processor->next_tag( array( 'tag_closers' => 'visit' ) ), "Did not find a tag opener when tag_closers was set to 'visit'" );
+ $this->assertFalse( $processor->next_tag( array( 'tag_closers' => 'visit' ) ), "Found a closer where there wasn't one" );
</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">@@ -554,38 +554,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::is_tag_closer
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_next_tag_should_stop_on_rcdata_and_script_tag_closers_when_requested() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<script>abc</script>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<script>abc</script>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</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">+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag( array( 'tag_closers' => 'visit' ) ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag( array( 'tag_closers' => 'visit' ) ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Should not have found closing SCRIPT tag when closing an opener.'
</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">- $p = new WP_HTML_Tag_Processor( 'abc</script>' );
- $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </script> tag closer when there was no tag opener' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( 'abc</script>' );
+ $this->assertTrue( $processor->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </script> tag closer when there was no tag opener' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<textarea>abc</textarea>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<textarea>abc</textarea>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</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">+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag( array( 'tag_closers' => 'visit' ) ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag( array( 'tag_closers' => 'visit' ) ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Should not have found closing TEXTAREA when closing an opener.'
</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">- $p = new WP_HTML_Tag_Processor( 'abc</textarea>' );
- $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </textarea> tag closer when there was no tag opener' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( 'abc</textarea>' );
+ $this->assertTrue( $processor->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </textarea> tag closer when there was no tag opener' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<title>abc</title>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<title>abc</title>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</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">+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag( array( 'tag_closers' => 'visit' ) ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag( array( 'tag_closers' => 'visit' ) ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Should not have found closing TITLE when closing an opener.'
</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">- $p = new WP_HTML_Tag_Processor( 'abc</title>' );
- $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </title> tag closer when there was no tag opener' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( 'abc</title>' );
+ $this->assertTrue( $processor->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </title> tag closer when there was no tag opener' );
</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">@@ -620,16 +620,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_attribute_on_a_non_existing_tag_does_not_change_the_markup() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->next_tag( 'p' ), 'Querying a non-existing tag did not return false' );
- $this->assertFalse( $p->next_tag( 'div' ), 'Querying a non-existing tag did not return false' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->next_tag( 'p' ), 'Querying a non-existing tag did not return false' );
+ $this->assertFalse( $processor->next_tag( 'div' ), 'Querying a non-existing tag did not return false' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->set_attribute( 'id', 'primary' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->set_attribute( 'id', 'primary' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> self::HTML_SIMPLE,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Calling get_updated_html after updating a non-existing tag returned an HTML that was different from the original HTML'
</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">@@ -643,8 +643,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_attribute_ops_on_tag_closer_do_not_change_the_markup() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div id=3></div invalid-id=4>' );
- $p->next_tag(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div id=3></div invalid-id=4>' );
+ $processor->next_tag(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_name' => 'div',
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_closers' => 'visit',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -651,9 +651,9 @@
</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">- $this->assertFalse( $p->is_tag_closer(), 'Skipped tag opener' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->is_tag_closer(), 'Skipped tag opener' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</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">+ $processor->next_tag(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_name' => 'div',
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_closers' => 'visit',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -660,14 +660,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">- $this->assertTrue( $p->is_tag_closer(), 'Skipped tag closer' );
- $this->assertFalse( $p->set_attribute( 'id', 'test' ), "Allowed setting an attribute on a tag closer when it shouldn't have" );
- $this->assertFalse( $p->remove_attribute( 'invalid-id' ), "Allowed removing an attribute on a tag closer when it shouldn't have" );
- $this->assertFalse( $p->add_class( 'sneaky' ), "Allowed adding a class on a tag closer when it shouldn't have" );
- $this->assertFalse( $p->remove_class( 'not-appearing-in-this-test' ), "Allowed removing a class on a tag closer when it shouldn't have" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->is_tag_closer(), 'Skipped tag closer' );
+ $this->assertFalse( $processor->set_attribute( 'id', 'test' ), "Allowed setting an attribute on a tag closer when it shouldn't have" );
+ $this->assertFalse( $processor->remove_attribute( 'invalid-id' ), "Allowed removing an attribute on a tag closer when it shouldn't have" );
+ $this->assertFalse( $processor->add_class( 'sneaky' ), "Allowed adding a class on a tag closer when it shouldn't have" );
+ $this->assertFalse( $processor->remove_class( 'not-appearing-in-this-test' ), "Allowed removing a class on a tag closer when it shouldn't have" );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div id=3></div invalid-id=4>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Calling get_updated_html after updating a non-existing tag returned an HTML that was different from the original HTML'
</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">@@ -676,9 +676,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Passing a double quote inside of an attribute value could lead to an XSS attack as follows:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * ```php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * $p = new WP_HTML_Tag_Processor( '<div class="header"></div>' );
- * $p->next_tag();
- * $p->set_attribute('class', '" onclick="alert');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * $processor = new WP_HTML_Tag_Processor( '<div class="header"></div>' );
+ * $processor->next_tag();
+ * $processor->set_attribute('class', '" onclick="alert');
</ins><span class="cx" style="display: block; padding: 0 10px"> * echo $p;
</span><span class="cx" style="display: block; padding: 0 10px"> * // <div class="" onclick="alert"></div>
</span><span class="cx" style="display: block; padding: 0 10px"> * ```
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -697,9 +697,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $attribute_value A value with potential XSS exploit.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_attribute_prevents_xss( $attribute_value ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div></div>' );
- $p->next_tag();
- $p->set_attribute( 'test', $attribute_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div></div>' );
+ $processor->next_tag();
+ $processor->set_attribute( 'test', $attribute_value );
</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"> * Testing the escaping is hard using tools that properly parse
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -713,7 +713,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * content and (b) looks at the raw values.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $match = null;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- preg_match( '~^<div test=(.*)></div>$~', $p->get_updated_html(), $match );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ preg_match( '~^<div test=(.*)></div>$~', $processor->get_updated_html(), $match );
</ins><span class="cx" style="display: block; padding: 0 10px"> list( , $actual_value ) = $match;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '"' . esc_attr( $attribute_value ) . '"', $actual_value, 'Entities were not properly escaped in the attribute value' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -724,7 +724,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return 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 function data_set_attribute_prevents_xss() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_set_attribute_prevents_xss() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> array( '"' ),
</span><span class="cx" style="display: block; padding: 0 10px"> array( '"' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -744,18 +744,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_attribute_with_a_non_existing_attribute_adds_a_new_attribute_to_the_markup() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->set_attribute( 'test-attribute', 'test-value' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->set_attribute( 'test-attribute', 'test-value' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div test-attribute="test-value" id="first"><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not include attribute added via set_attribute()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'test-value',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'test-attribute' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'test-attribute' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called after get_updated_html()) did not return attribute added via set_attribute()'
</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">@@ -766,18 +766,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_returns_updated_values_before_they_are_applied() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->set_attribute( 'test-attribute', 'test-value' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->set_attribute( 'test-attribute', 'test-value' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'test-value',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'test-attribute' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'test-attribute' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called before get_updated_html()) did not return attribute added via set_attribute()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div test-attribute="test-value" id="first"><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not include attribute added via set_attribute()'
</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">@@ -788,18 +788,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_returns_updated_values_before_they_are_applied_with_different_name_casing() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->set_attribute( 'test-ATTribute', 'test-value' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->set_attribute( 'test-ATTribute', 'test-value' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'test-value',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'test-attribute' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'test-attribute' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called before get_updated_html()) did not return attribute added via set_attribute()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div test-ATTribute="test-value" id="first"><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not include attribute added via set_attribute()'
</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">@@ -810,18 +810,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_reflects_added_class_names_before_they_are_applied() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->add_class( 'my-class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->add_class( 'my-class' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'my-class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called before get_updated_html()) did not return class name added via add_class()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="my-class" id="first"><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not include class name added via add_class()'
</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">@@ -832,26 +832,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_reflects_added_class_names_before_they_are_applied_and_retains_classes_from_previous_add_class_calls() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->add_class( 'my-class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->add_class( 'my-class' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'my-class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called before get_updated_html()) did not return class name added via add_class()'
</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">- $p->add_class( 'my-other-class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->add_class( 'my-other-class' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'my-class my-other-class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called before get_updated_html()) did not return class names added via subsequent add_class() calls'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="my-class my-other-class" id="first"><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not include class names added via subsequent add_class() calls'
</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">@@ -862,17 +862,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_reflects_removed_attribute_before_it_is_applied() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->remove_attribute( 'id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->remove_attribute( 'id' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'id' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'id' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called before get_updated_html()) returned attribute that was removed by remove_attribute()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div ><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML includes attribute that was removed by remove_attribute()'
</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">@@ -883,18 +883,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_reflects_adding_and_then_removing_an_attribute_before_those_updates_are_applied() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->set_attribute( 'test-attribute', 'test-value' );
- $p->remove_attribute( 'test-attribute' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->set_attribute( 'test-attribute', 'test-value' );
+ $processor->remove_attribute( 'test-attribute' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'test-attribute' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'test-attribute' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called before get_updated_html()) returned attribute that was added via set_attribute() and then removed by remove_attribute()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> self::HTML_SIMPLE,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML includes attribute that was added via set_attribute() and then removed by remove_attribute()'
</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">@@ -905,18 +905,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_reflects_setting_and_then_removing_an_existing_attribute_before_those_updates_are_applied() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->set_attribute( 'id', 'test-value' );
- $p->remove_attribute( 'id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->set_attribute( 'id', 'test-value' );
+ $processor->remove_attribute( 'id' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'id' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'id' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called before get_updated_html()) returned attribute that was overwritten by set_attribute() and then removed by remove_attribute()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div ><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML includes attribute that was overwritten by set_attribute() and then removed by remove_attribute()'
</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">@@ -927,18 +927,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_reflects_removed_class_names_before_they_are_applied() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->remove_class( 'with-border' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->remove_class( 'with-border' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'main',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called before get_updated_html()) returned the wrong attribute after calling remove_attribute()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="main" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML includes wrong attribute after calling remove_attribute()'
</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">@@ -949,19 +949,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_reflects_setting_and_then_removing_a_class_name_before_those_updates_are_applied() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->add_class( 'foo-class' );
- $p->remove_class( 'foo-class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->add_class( 'foo-class' );
+ $processor->remove_class( 'foo-class' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'main with-border',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called before get_updated_html()) returned class name that was added via add_class() and then removed by remove_class()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> self::HTML_WITH_CLASSES,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML includes class that was added via add_class() and then removed by remove_class()'
</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">@@ -972,19 +972,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::get_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_attribute_reflects_duplicating_and_then_removing_an_existing_class_name_before_those_updates_are_applied() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->add_class( 'with-border' );
- $p->remove_class( 'with-border' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->add_class( 'with-border' );
+ $processor->remove_class( 'with-border' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'main',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'get_attribute() (called before get_updated_html()) returned class name that was duplicated via add_class() and then removed by remove_class()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="main" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML includes class that was duplicated via add_class() and then removed by remove_class()'
</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">@@ -998,13 +998,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_first_attribute_when_duplicated_attributes_exist() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div id="update-me" id="ignored-id"><span id="second">Text</span></div>' );
- $p->next_tag();
- $p->set_attribute( 'id', 'updated-id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div id="update-me" id="ignored-id"><span id="second">Text</span></div>' );
+ $processor->next_tag();
+ $processor->set_attribute( 'id', 'updated-id' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div id="updated-id" id="ignored-id"><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Proper (first) appearance of attribute was not updated when duplicates exist'
</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">@@ -1015,12 +1015,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_attribute_with_an_existing_attribute_name_updates_its_value_in_the_markup() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->set_attribute( 'id', 'new-id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->set_attribute( 'id', 'new-id' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div id="new-id"><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Existing attribute was not updated'
</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">@@ -1034,13 +1034,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_attribute_with_case_variants_updates_only_the_original_first_copy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div data-enabled="5">' );
- $p->next_tag();
- $p->set_attribute( 'DATA-ENABLED', 'canary' );
- $p->set_attribute( 'Data-Enabled', 'canary' );
- $p->set_attribute( 'dATa-EnABled', 'canary' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div data-enabled="5">' );
+ $processor->next_tag();
+ $processor->set_attribute( 'DATA-ENABLED', 'canary' );
+ $processor->set_attribute( 'Data-Enabled', 'canary' );
+ $processor->set_attribute( 'dATa-EnABled', 'canary' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '<div data-enabled="canary">', strtolower( $p->get_updated_html() ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '<div data-enabled="canary">', strtolower( $processor->get_updated_html() ) );
</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">@@ -1050,14 +1050,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_next_tag_and_set_attribute_in_a_loop_update_all_tags_in_the_markup() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- while ( $p->next_tag() ) {
- $p->set_attribute( 'data-foo', 'bar' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ while ( $processor->next_tag() ) {
+ $processor->set_attribute( 'data-foo', 'bar' );
</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"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div data-foo="bar" id="first"><span data-foo="bar" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Not all tags were updated when looping with next_tag() and set_attribute()'
</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">@@ -1073,13 +1073,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_first_when_duplicated_attribute() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div id="update-me" id="ignored-id"><span id="second">Text</span></div>' );
- $p->next_tag();
- $p->remove_attribute( 'id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div id="update-me" id="ignored-id"><span id="second">Text</span></div>' );
+ $processor->next_tag();
+ $processor->remove_attribute( 'id' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringNotContainsString(
</span><span class="cx" style="display: block; padding: 0 10px"> 'update-me',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'First attribute (when duplicates exist) was not removed'
</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">@@ -1090,13 +1090,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_attribute_with_an_existing_attribute_name_removes_it_from_the_markup() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->remove_attribute( 'id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->remove_attribute( 'id' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div ><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Attribute was not removed'
</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">@@ -1111,16 +1111,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @dataProvider data_html_with_duplicated_attributes
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_attribute_with_duplicated_attributes_removes_all_of_them( $html_with_duplicate_attributes, $attribute_to_remove ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $html_with_duplicate_attributes );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $html_with_duplicate_attributes );
+ $processor->next_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">- $p->remove_attribute( $attribute_to_remove );
- $this->assertNull( $p->get_attribute( $attribute_to_remove ), 'Failed to remove all copies of an attribute when duplicated in modified source.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->remove_attribute( $attribute_to_remove );
+ $this->assertNull( $processor->get_attribute( $attribute_to_remove ), 'Failed to remove all copies of an attribute when duplicated in modified source.' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Recreate a tag processor with the updated HTML after removing the attribute.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $p->get_updated_html() );
- $p->next_tag();
- $this->assertNull( $p->get_attribute( $attribute_to_remove ), 'Failed to remove all copies of duplicated attributes when getting updated HTML.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $processor->get_updated_html() );
+ $processor->next_tag();
+ $this->assertNull( $processor->get_attribute( $attribute_to_remove ), 'Failed to remove all copies of duplicated attributes when getting updated HTML.' );
</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">@@ -1131,12 +1131,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_previous_duplicated_attributes_are_not_removed_on_successive_tag_removal() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<span id=one id=two id=three><span id=four>' );
- $p->next_tag();
- $p->next_tag();
- $p->remove_attribute( 'id' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<span id=one id=two id=three><span id=four>' );
+ $processor->next_tag();
+ $processor->next_tag();
+ $processor->remove_attribute( 'id' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '<span id=one id=two id=three><span >', $p->get_updated_html() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( '<span id=one id=two id=three><span >', $processor->get_updated_html() );
</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">@@ -1146,7 +1146,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[].
</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 data_html_with_duplicated_attributes() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_html_with_duplicated_attributes() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Double attributes' => array( '<div id=one id=two>', 'id' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Triple attributes' => array( '<div id=one id=two id=three>', 'id' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1162,13 +1162,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_attribute_with_a_non_existing_attribute_name_does_not_change_the_markup() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->remove_attribute( 'no-such-attribute' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->remove_attribute( 'no-such-attribute' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> self::HTML_SIMPLE,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Content was changed when attempting to remove an attribute that did not exist'
</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">@@ -1179,18 +1179,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::add_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_class_creates_a_class_attribute_when_there_is_none() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->add_class( 'foo-class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->add_class( 'foo-class' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="foo-class" id="first"><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not include class name added via add_class()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'foo-class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute( 'class' ) did not return class name added via add_class()"
</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">@@ -1201,19 +1201,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::add_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_calling_add_class_twice_creates_a_class_attribute_with_both_class_names_when_there_is_no_class_attribute() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->add_class( 'foo-class' );
- $p->add_class( 'bar-class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->add_class( 'foo-class' );
+ $processor->add_class( 'bar-class' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="foo-class bar-class" id="first"><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not include class names added via subsequent add_class() calls'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'foo-class bar-class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute( 'class' ) did not return class names added via subsequent add_class() calls"
</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">@@ -1224,17 +1224,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_class_does_not_change_the_markup_when_there_is_no_class_attribute() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->remove_class( 'foo-class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->remove_class( 'foo-class' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> self::HTML_SIMPLE,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML includes class name that was removed by remove_class()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute( 'class' ) did not return null for class name that was removed by remove_class()"
</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">@@ -1245,19 +1245,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::add_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_class_appends_class_names_to_the_existing_class_attribute_when_one_already_exists() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->add_class( 'foo-class' );
- $p->add_class( 'bar-class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->add_class( 'foo-class' );
+ $processor->add_class( 'bar-class' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="main with-border foo-class bar-class" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not reflect class names added to existing class attribute via subsequent add_class() calls'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'main with-border foo-class bar-class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute( 'class' ) does not reflect class names added to existing class attribute via subsequent add_class() calls"
</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">@@ -1268,18 +1268,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_class_removes_a_single_class_from_the_class_attribute_when_one_exists() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->remove_class( 'main' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->remove_class( 'main' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class=" with-border" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not reflect class name removed from existing class attribute via remove_class()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> ' with-border',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute( 'class' ) does not reflect class name removed from existing class attribute via remove_class()"
</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">@@ -1290,18 +1290,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_calling_remove_class_with_all_listed_class_names_removes_the_existing_class_attribute_from_the_markup() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->remove_class( 'main' );
- $p->remove_class( 'with-border' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->remove_class( 'main' );
+ $processor->remove_class( 'with-border' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not reflect class attribute removed via subesequent remove_class() calls'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute( 'class' ) did not return null for class attribute removed via subesequent remove_class() calls"
</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">@@ -1312,18 +1312,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::add_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_class_does_not_add_duplicate_class_names() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->add_class( 'with-border' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->add_class( 'with-border' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="main with-border" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not reflect deduplicated class name added via add_class()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'main with-border',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute( 'class' ) does not reflect deduplicated class name added via add_class()"
</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">@@ -1334,18 +1334,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::add_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_class_preserves_class_name_order_when_a_duplicate_class_name_is_added() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->add_class( 'main' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->add_class( 'main' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="main with-border" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not reflect class name order after adding duplicated class name via add_class()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'main with-border',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute( 'class' ) does not reflect class name order after adding duplicated class name added via add_class()"
</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">@@ -1356,20 +1356,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::add_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_class_when_there_is_a_class_attribute_with_excessive_whitespaces() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor(
</ins><span class="cx" style="display: block; padding: 0 10px"> '<div class=" main with-border " id="first"><span class="not-main bold with-border" id="second">Text</span></div>'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag();
- $p->add_class( 'foo-class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag();
+ $processor->add_class( 'foo-class' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class=" main with-border foo-class" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not reflect existing excessive whitespace after adding class name via add_class()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> ' main with-border foo-class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute( 'class' ) does not reflect existing excessive whitespace after adding class name via add_class()"
</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">@@ -1380,20 +1380,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_class_preserves_whitespaces_when_there_is_a_class_attribute_with_excessive_whitespaces() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor(
</ins><span class="cx" style="display: block; padding: 0 10px"> '<div class=" main with-border " id="first"><span class="not-main bold with-border" id="second">Text</span></div>'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag();
- $p->remove_class( 'with-border' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag();
+ $processor->remove_class( 'with-border' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class=" main" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not reflect existing excessive whitespace after removing class name via remove_class()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> ' main',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute( 'class' ) does not reflect existing excessive whitespace after removing class name via removing_class()"
</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">@@ -1404,19 +1404,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_removing_all_classes_removes_the_existing_class_attribute_from_the_markup_even_when_excessive_whitespaces_are_present() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor(
</ins><span class="cx" style="display: block; padding: 0 10px"> '<div class=" main with-border " id="first"><span class="not-main bold with-border" id="second">Text</span></div>'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag();
- $p->remove_class( 'main' );
- $p->remove_class( 'with-border' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag();
+ $processor->remove_class( 'main' );
+ $processor->remove_class( 'with-border' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Updated HTML does not reflect removed class attribute after removing all class names via remove_class()'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute( 'class' ) did not return null after removing all class names via remove_class()"
</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">@@ -1435,33 +1435,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_attribute_takes_priority_over_add_class() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->add_class( 'add_class' );
- $p->set_attribute( 'class', 'set_attribute' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->add_class( 'add_class' );
+ $processor->set_attribute( 'class', 'set_attribute' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="set_attribute" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Calling get_updated_html after updating first tag's attributes did not return the expected HTML"
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'set_attribute',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Calling get_attribute after updating first tag's attributes did not return the expected class name"
</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">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->set_attribute( 'class', 'set_attribute' );
- $p->add_class( 'add_class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->set_attribute( 'class', 'set_attribute' );
+ $processor->add_class( 'add_class' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="set_attribute add_class" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Calling get_updated_html after updating first tag's attributes did not return the expected HTML"
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'set_attribute add_class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Calling get_attribute after updating first tag's attributes did not return the expected class name"
</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">@@ -1482,33 +1482,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_attribute_takes_priority_over_add_class_even_before_updating() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->add_class( 'add_class' );
- $p->set_attribute( 'class', 'set_attribute' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->add_class( 'add_class' );
+ $processor->set_attribute( 'class', 'set_attribute' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'set_attribute',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Calling get_attribute after updating first tag's attributes did not return the expected class name"
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="set_attribute" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Calling get_updated_html after updating first tag's attributes did not return the expected HTML"
</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">- $p = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
- $p->next_tag();
- $p->set_attribute( 'class', 'set_attribute' );
- $p->add_class( 'add_class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_WITH_CLASSES );
+ $processor->next_tag();
+ $processor->set_attribute( 'class', 'set_attribute' );
+ $processor->add_class( 'add_class' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'set_attribute add_class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Calling get_attribute after updating first tag's attributes did not return the expected class name"
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="set_attribute add_class" id="first"><span class="not-main bold with-border" id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Calling get_updated_html after updating first tag's attributes did not return the expected HTML"
</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">@@ -1519,18 +1519,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::add_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_class_overrides_boolean_class_attribute() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->set_attribute( 'class', true );
- $p->add_class( 'add_class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->set_attribute( 'class', true );
+ $processor->add_class( 'add_class' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="add_class" id="first"><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Updated HTML doesn't reflect class added via add_class that was originally set as boolean attribute"
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'add_class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute (called after get_updated_html()) doesn't reflect class added via add_class that was originally set as boolean attribute"
</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">@@ -1541,18 +1541,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::add_class
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_class_overrides_boolean_class_attribute_even_before_updating() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
- $p->next_tag();
- $p->set_attribute( 'class', true );
- $p->add_class( 'add_class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_SIMPLE );
+ $processor->next_tag();
+ $processor->set_attribute( 'class', true );
+ $processor->add_class( 'add_class' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'add_class',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'class' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'class' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> "get_attribute (called before get_updated_html()) doesn't reflect class added via add_class that was originally set as boolean attribute"
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="add_class" id="first"><span id="second">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Updated HTML doesn't reflect class added via add_class that was originally set as boolean attribute"
</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">@@ -1613,12 +1613,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> HTML;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $input );
- $this->assertTrue( $p->next_tag( 'div' ), 'Did not find first DIV tag in input.' );
- $p->set_attribute( 'data-details', '{ "key": "value" }' );
- $p->add_class( 'is-processed' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $input );
+ $this->assertTrue( $processor->next_tag( 'div' ), 'Did not find first DIV tag in input.' );
+ $processor->set_attribute( 'data-details', '{ "key": "value" }' );
+ $processor->add_class( 'is-processed' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</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">+ $processor->next_tag(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_name' => 'div',
</span><span class="cx" style="display: block; padding: 0 10px"> 'class_name' => 'BtnGroup',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1626,11 +1626,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Did not find the first BtnGroup DIV 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">- $p->remove_class( 'BtnGroup' );
- $p->add_class( 'button-group' );
- $p->add_class( 'Another-Mixed-Case' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->remove_class( 'BtnGroup' );
+ $processor->add_class( 'button-group' );
+ $processor->add_class( 'Another-Mixed-Case' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</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">+ $processor->next_tag(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_name' => 'div',
</span><span class="cx" style="display: block; padding: 0 10px"> 'class_name' => 'BtnGroup',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1638,11 +1638,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Did not find the second BtnGroup DIV 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">- $p->remove_class( 'BtnGroup' );
- $p->add_class( 'button-group' );
- $p->add_class( 'Another-Mixed-Case' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->remove_class( 'BtnGroup' );
+ $processor->add_class( 'button-group' );
+ $processor->add_class( 'Another-Mixed-Case' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</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">+ $processor->next_tag(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_name' => 'button',
</span><span class="cx" style="display: block; padding: 0 10px"> 'class_name' => 'btn',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1651,10 +1651,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Did not find third BUTTON tag with "btn" CSS class'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->remove_attribute( 'class' );
- $this->assertFalse( $p->next_tag( 'non-existent' ), "Found a {$p->get_tag()} tag when none should have been found." );
- $p->set_attribute( 'class', 'test' );
- $this->assertSame( $expected_output, $p->get_updated_html(), 'Calling get_updated_html after updating the attributes did not return the expected HTML' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->remove_attribute( 'class' );
+ $this->assertFalse( $processor->next_tag( 'non-existent' ), "Found a {$processor->get_tag()} tag when none should have been found." );
+ $processor->set_attribute( 'class', 'test' );
+ $this->assertSame( $expected_output, $processor->get_updated_html(), 'Calling get_updated_html after updating the attributes did not return the expected HTML' );
</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">@@ -1663,26 +1663,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::next_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_correctly_parses_html_attributes_wrapped_in_single_quotation_marks() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor(
</ins><span class="cx" style="display: block; padding: 0 10px"> '<div id=\'first\'><span id=\'second\'>Text</span></div>'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</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">+ $processor->next_tag(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_name' => 'div',
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => 'first',
</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">- $p->remove_attribute( 'id' );
- $p->next_tag(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->remove_attribute( 'id' );
+ $processor->next_tag(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'tag_name' => 'span',
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => 'second',
</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">- $p->set_attribute( 'id', 'single-quote' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->set_attribute( 'id', 'single-quote' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div ><span id="single-quote">Text</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not remove single-quoted attribute'
</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">@@ -1693,14 +1693,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_attribute_with_value_equal_to_true_adds_a_boolean_html_attribute_with_implicit_value() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor(
</ins><span class="cx" style="display: block; padding: 0 10px"> '<form action="/action_page.php"><input type="checkbox" name="vehicle" value="Bike"><label for="vehicle">I have a bike</label></form>'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag( 'input' );
- $p->set_attribute( 'checked', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag( 'input' );
+ $processor->set_attribute( 'checked', true );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<form action="/action_page.php"><input checked type="checkbox" name="vehicle" value="Bike"><label for="vehicle">I have a bike</label></form>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not add "checked" as an expected boolean attribute'
</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">@@ -1711,14 +1711,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_setting_a_boolean_attribute_to_false_removes_it_from_the_markup() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor(
</ins><span class="cx" style="display: block; padding: 0 10px"> '<form action="/action_page.php"><input checked type="checkbox" name="vehicle" value="Bike"><label for="vehicle">I have a bike</label></form>'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag( 'input' );
- $p->set_attribute( 'checked', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag( 'input' );
+ $processor->set_attribute( 'checked', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<form action="/action_page.php"><input type="checkbox" name="vehicle" value="Bike"><label for="vehicle">I have a bike</label></form>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not remove boolean attribute when set to false'
</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">@@ -1730,12 +1730,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_setting_a_missing_attribute_to_false_does_not_change_the_markup() {
</span><span class="cx" style="display: block; padding: 0 10px"> $html_input = '<form action="/action_page.php"><input type="checkbox" name="vehicle" value="Bike"><label for="vehicle">I have a bike</label></form>';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $html_input );
- $p->next_tag( 'input' );
- $p->set_attribute( 'checked', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $html_input );
+ $processor->next_tag( 'input' );
+ $processor->set_attribute( 'checked', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> $html_input,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Changed the markup unexpectedly when setting a non-existing attribute to false'
</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">@@ -1746,14 +1746,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_setting_a_boolean_attribute_to_a_string_value_adds_explicit_value_to_the_markup() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor(
</ins><span class="cx" style="display: block; padding: 0 10px"> '<form action="/action_page.php"><input checked type="checkbox" name="vehicle" value="Bike"><label for="vehicle">I have a bike</label></form>'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag( 'input' );
- $p->set_attribute( 'checked', 'checked' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag( 'input' );
+ $processor->set_attribute( 'checked', 'checked' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<form action="/action_page.php"><input checked="checked" type="checkbox" name="vehicle" value="Bike"><label for="vehicle">I have a bike</label></form>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not add string value to existing boolean attribute'
</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">@@ -1765,18 +1765,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::paused_at_incomplete_token
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_unclosed_script_tag_should_not_cause_an_infinite_loop() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<script><div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<script><div>' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse(
</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">+ $processor->next_tag(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Should not have stopped on an opening SCRIPT tag without a proper closing tag in the document.'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->paused_at_incomplete_token(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->paused_at_incomplete_token(),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Should have paused the parser because of the incomplete SCRIPT tag but didn't."
</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"> // Run this to ensure that the test ends (not in an infinite loop).
</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">+ $processor->next_tag();
</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">@@ -1789,11 +1789,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $script_then_div HTML to test.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_next_tag_ignores_script_tag_contents( $script_then_div ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $script_then_div );
- $p->next_tag();
- $this->assertSame( 'SCRIPT', $p->get_tag(), 'The first found tag was not "script"' );
- $p->next_tag();
- $this->assertSame( 'DIV', $p->get_tag(), 'The second found tag was not "div"' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $script_then_div );
+ $processor->next_tag();
+ $this->assertSame( 'SCRIPT', $processor->get_tag(), 'The first found tag was not "script"' );
+ $processor->next_tag();
+ $this->assertSame( 'DIV', $processor->get_tag(), 'The second found tag was not "div"' );
</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">@@ -1801,7 +1801,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[].
</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 data_next_tag_ignores_script_tag_contents() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_next_tag_ignores_script_tag_contents() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Simple script tag' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> '<script><span class="d-none d-md-inline">Back to notifications</span></script><div></div>',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1866,11 +1866,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * element after contain the "start" and "end" CSS classes.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_next_tag_ignores_invalid_first_character_of_tag_name_comments( $html_with_markers ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $html_with_markers );
- $p->next_tag( array( 'class_name' => 'start' ) );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $html_with_markers );
+ $processor->next_tag( array( 'class_name' => 'start' ) );
+ $processor->next_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">- $this->assertSame( 'end', $p->get_attribute( 'class' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 'end', $processor->get_attribute( 'class' ) );
</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">@@ -1878,7 +1878,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_next_tag_ignores_invalid_first_character_of_tag_name_comments() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_next_tag_ignores_invalid_first_character_of_tag_name_comments() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Invalid tag openers as normal text' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> '<ul><li><div class=start>I <3 when outflow > inflow</div><img class=end></li></ul>',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1905,11 +1905,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $rcdata_tag RCDATA tag.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_next_tag_ignores_contents_of_rcdata_tag( $rcdata_then_div, $rcdata_tag ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $rcdata_then_div );
- $p->next_tag();
- $this->assertSame( $rcdata_tag, $p->get_tag(), "The first found tag was not '$rcdata_tag'" );
- $p->next_tag();
- $this->assertSame( 'DIV', $p->get_tag(), "The second found tag was not 'div'" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $rcdata_then_div );
+ $processor->next_tag();
+ $this->assertSame( $rcdata_tag, $processor->get_tag(), "The first found tag was not '$rcdata_tag'" );
+ $processor->next_tag();
+ $this->assertSame( 'DIV', $processor->get_tag(), "The second found tag was not 'div'" );
</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">@@ -1917,7 +1917,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_next_tag_ignores_contents_of_rcdata_tag() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_next_tag_ignores_contents_of_rcdata_tag() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'simple textarea' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'rcdata_then_div' => '<textarea><span class="d-none d-md-inline">Back to notifications</span></textarea><div></div>',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1964,10 +1964,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::next_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_processes_inside_of_noscript_elements() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<noscript><input type="submit"></noscript><div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<noscript><input type="submit"></noscript><div>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->next_tag( 'INPUT' ), 'Failed to find INPUT element inside NOSCRIPT element.' );
- $this->assertTrue( $p->next_tag( 'DIV' ), 'Failed to find DIV element after NOSCRIPT element.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->next_tag( 'INPUT' ), 'Failed to find INPUT element inside NOSCRIPT element.' );
+ $this->assertTrue( $processor->next_tag( 'DIV' ), 'Failed to find DIV element after NOSCRIPT element.' );
</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">@@ -1996,7 +1996,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[].
</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 data_next_tag_ignores_contents_of_rawtext_tags() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_next_tag_ignores_contents_of_rawtext_tags() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'IFRAME' => array( '<iframe><section>Inside</section></iframe><section target>' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'NOEMBED' => array( '<noembed><p></p></noembed><div target>' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2012,11 +2012,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::class_list
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_class_list_empty_when_missing_class() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div>' );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div>' );
+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found_classes = false;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $p->class_list() as $class ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $processor->class_list() as $class ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $found_classes = true;
</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">@@ -2029,11 +2029,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::class_list
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_class_list_empty_when_class_is_boolean() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div class>' );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div class>' );
+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found_classes = false;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $p->class_list() as $class ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $processor->class_list() as $class ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $found_classes = true;
</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">@@ -2046,11 +2046,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::class_list
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_class_list_empty_when_class_is_empty() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div class="">' );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div class="">' );
+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found_classes = false;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $p->class_list() as $class ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $processor->class_list() as $class ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $found_classes = true;
</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">@@ -2063,11 +2063,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::class_list
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_class_list_visits_each_class_in_order() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div class="one two three">' );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div class="one two three">' );
+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found_classes = array();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $p->class_list() as $class ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $processor->class_list() as $class ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $found_classes[] = $class;
</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">@@ -2080,11 +2080,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::class_list
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_class_list_decodes_class_names() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div class="∉-class <egg> #">' );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div class="∉-class <egg> #">' );
+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found_classes = array();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $p->class_list() as $class ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $processor->class_list() as $class ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $found_classes[] = $class;
</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">@@ -2097,11 +2097,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::class_list
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_class_list_visits_unique_class_names_only_once() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<div class="one one one">' );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<div class="one one one">' );
+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found_classes = array();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $p->class_list() as $class ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $processor->class_list() as $class ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $found_classes[] = $class;
</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">@@ -2120,13 +2120,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $has_class Whether the sought class exists in the given HTML.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_class_handles_expected_class_name_variations( $html, $sought_class, $has_class ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $html );
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $html );
+ $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $has_class ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( $p->has_class( $sought_class ), "Failed to find expected class {$sought_class}." );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( $processor->has_class( $sought_class ), "Failed to find expected class {$sought_class}." );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $p->has_class( $sought_class ), "Found class {$sought_class} when it doesn't exist." );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $processor->has_class( $sought_class ), "Found class {$sought_class} when it doesn't exist." );
</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">@@ -2135,7 +2135,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_html_with_variations_of_class_values_and_sought_class_names() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_html_with_variations_of_class_values_and_sought_class_names() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Tag without any classes' => array( '<div>', 'foo', false ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Tag with boolean class' => array( '<img class>', 'foo', false ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2159,16 +2159,16 @@
</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"> public function test_allows_incorrectly_closed_comments() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<img id=before><!-- <img id=inside> --!><img id=after>--><img id=final>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<img id=before><!-- <img id=inside> --!><img id=after>--><img id=final>' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag();
- $this->assertSame( 'before', $p->get_attribute( 'id' ), 'Did not find starting tag.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag();
+ $this->assertSame( 'before', $processor->get_attribute( 'id' ), 'Did not find starting 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">- $p->next_tag();
- $this->assertSame( 'after', $p->get_attribute( 'id' ), 'Did not properly close improperly-closed comment.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag();
+ $this->assertSame( 'after', $processor->get_attribute( 'id' ), 'Did not properly close improperly-closed comment.' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag();
- $this->assertSame( 'final', $p->get_attribute( 'id' ), 'Did not skip over unopened comment-closer.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag();
+ $this->assertSame( 'final', $processor->get_attribute( 'id' ), 'Did not skip over unopened comment-closer.' );
</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">@@ -2184,15 +2184,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $html_ending_before_comment_close HTML with opened comments that aren't closed.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_documents_may_end_with_unclosed_comment( $html_ending_before_comment_close ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $html_ending_before_comment_close );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $html_ending_before_comment_close );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag(),
- "Should not have found any tag, but found {$p->get_tag()}."
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag(),
+ "Should not have found any tag, but found {$processor->get_tag()}."
</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"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->paused_at_incomplete_token(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->paused_at_incomplete_token(),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Should have indicated that the parser found an incomplete token but didn't."
</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">@@ -2202,7 +2202,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_html_with_unclosed_comments() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_html_with_unclosed_comments() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Shortest open valid comment' => array( '<!--' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Basic truncated comment' => array( '<!-- this ends --' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2225,11 +2225,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $html_with_after_marker HTML to test with "id=after" on element immediately following an abruptly closed comment.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_closes_abrupt_closing_of_empty_comment( $html_with_after_marker ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $html_with_after_marker );
- $p->next_tag();
- $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $html_with_after_marker );
+ $processor->next_tag();
+ $processor->next_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">- $this->assertSame( 'after', $p->get_attribute( 'id' ), 'Did not find tag after closing abruptly-closed comment' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 'after', $processor->get_attribute( 'id' ), 'Did not find tag after closing abruptly-closed comment' );
</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">@@ -2237,7 +2237,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_abruptly_closed_empty_comments() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_abruptly_closed_empty_comments() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Empty comment with two dashes only' => array( '<hr><!--><hr id=after>' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Empty comment with two dashes only, improperly closed' => array( '<hr><!--!><hr id=inside>--><hr id=after>' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2262,11 +2262,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param $input_html HTML with multiple divs, one of which carries the "target" attribute.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_skips_contents_of_script_and_rcdata_regions( $input_html ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $input_html );
- $p->next_tag( 'div' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $input_html );
+ $processor->next_tag( 'div' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_attribute( 'target' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_attribute( 'target' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not properly skip over script and rcdata regions; incorrectly found tags inside'
</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">@@ -2276,7 +2276,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_skips_contents_of_script_and_rcdata_regions() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_skips_contents_of_script_and_rcdata_regions() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Balanced SCRIPT tags' => array( '<script>console.log("<div>");</script><div target><div>' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Unexpected SCRIPT closer after DIV' => array( 'console.log("<div target>")</script><div><div>' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2295,16 +2295,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_can_query_and_update_wrongly_nested_tags() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor(
</ins><span class="cx" style="display: block; padding: 0 10px"> '<span>123<p>456</span>789</p>'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag( 'span' );
- $p->set_attribute( 'class', 'span-class' );
- $p->next_tag( 'p' );
- $p->set_attribute( 'class', 'p-class' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag( 'span' );
+ $processor->set_attribute( 'class', 'span-class' );
+ $processor->next_tag( 'p' );
+ $processor->set_attribute( 'class', 'p-class' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<span class="span-class">123<p class="p-class">456</span>789</p>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not find overlapping p tag'
</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">@@ -2316,12 +2316,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::remove_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_removing_specific_attributes_in_malformed_html() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_MALFORMED );
- $p->next_tag( 'span' );
- $p->remove_attribute( 'Notifications<' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_MALFORMED );
+ $processor->next_tag( 'span' );
+ $processor->remove_attribute( 'Notifications<' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div><span class="d-md-none" /span><span class="d-none d-md-inline">Back to notifications</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not remove "Notifications<" attribute in malformed input'
</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">@@ -2357,7 +2357,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_html_without_tags() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_html_without_tags() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'DOCTYPE declaration' => array( '<!DOCTYPE html>Just some HTML' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'No tags' => array( 'this is nothing more than a text node' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2382,15 +2382,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $incomplete_html HTML text containing some kind of incomplete syntax.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_next_tag_returns_false_for_incomplete_syntax_elements( $incomplete_html ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $incomplete_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $incomplete_html );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->next_tag(),
- "Shouldn't have found any tags but found {$p->get_tag()}."
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->next_tag(),
+ "Shouldn't have found any tags but found {$processor->get_tag()}."
</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"> $this->assertTrue(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->paused_at_incomplete_token(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->paused_at_incomplete_token(),
</ins><span class="cx" style="display: block; padding: 0 10px"> "Should have indicated that the parser found an incomplete token but didn't."
</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">@@ -2400,7 +2400,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_incomplete_syntax_elements() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_incomplete_syntax_elements() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Incomplete tag name' => array( '<swit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'Incomplete tag (no attributes)' => array( '<div' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2442,14 +2442,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::set_attribute
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_updating_specific_attributes_in_malformed_html() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( self::HTML_MALFORMED );
- $p->next_tag( 'span' );
- $p->set_attribute( 'id', 'first' );
- $p->next_tag( 'span' );
- $p->set_attribute( 'id', 'second' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( self::HTML_MALFORMED );
+ $processor->next_tag( 'span' );
+ $processor->set_attribute( 'id', 'first' );
+ $processor->next_tag( 'span' );
+ $processor->set_attribute( 'id', 'second' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div><span id="first" class="d-md-none" Notifications</span><span id="second" class="d-none d-md-inline">Back to notifications</span></div>',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not add id attributes properly to malformed input'
</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">@@ -2466,16 +2466,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $expected Expected updated HTML.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_updating_attributes( $html, $expected ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $html );
- $p->next_tag();
- $p->set_attribute( 'foo', 'bar' );
- $p->add_class( 'firstTag' );
- $p->next_tag();
- $p->add_class( 'secondTag' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $html );
+ $processor->next_tag();
+ $processor->set_attribute( 'foo', 'bar' );
+ $processor->add_class( 'firstTag' );
+ $processor->next_tag();
+ $processor->add_class( 'secondTag' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> $expected,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not properly add attributes and class names'
</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">@@ -2485,7 +2485,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_updating_attributes() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_updating_attributes() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'tags inside of a comment' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'input' => '<!-- this is a comment. no <strong>tags</strong> allowed --><span>test</span>',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2530,16 +2530,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $expected Expected updated HTML.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_updating_attributes_in_malformed_html( $html, $expected ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( $html );
- $this->assertTrue( $p->next_tag(), 'Could not find first tag.' );
- $p->set_attribute( 'foo', 'bar' );
- $p->add_class( 'firstTag' );
- $p->next_tag();
- $p->add_class( 'secondTag' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( $html );
+ $this->assertTrue( $processor->next_tag(), 'Could not find first tag.' );
+ $processor->set_attribute( 'foo', 'bar' );
+ $processor->add_class( 'firstTag' );
+ $processor->next_tag();
+ $processor->add_class( 'secondTag' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> $expected,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p->get_updated_html(),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor->get_updated_html(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'Did not properly update attributes and classnames given malformed input'
</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">@@ -2549,7 +2549,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array[]
</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 data_updating_attributes_in_malformed_html() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function data_updating_attributes_in_malformed_html() {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Invalid entity inside attribute value' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'input' => '<img src="https://s0.wp.com/i/atat.png" title="&; First <title> is ¬it;" TITLE="second title" title="An Imperial &imperial; AT-AT"><span>test</span>',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2702,8 +2702,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::next_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_handles_malformed_taglike_open_short_html() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '<' );
- $result = $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '<' );
+ $result = $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $result, 'Did not handle "<" html properly.' );
</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">@@ -2711,8 +2711,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_HTML_Tag_Processor::next_tag
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_handles_malformed_taglike_close_short_html() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( '</ ' );
- $result = $p->next_tag();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( '</ ' );
+ $result = $processor->next_tag();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $result, 'Did not handle "</ " html properly.' );
</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">@@ -2722,9 +2722,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 60385
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_single_text_node_with_taglike_text() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $p = new WP_HTML_Tag_Processor( 'test< /A>' );
- $p->next_token();
- $this->assertSame( '#text', $p->get_token_type(), 'Did not find text node.' );
- $this->assertSame( 'test< /A>', $p->get_modifiable_text(), 'Did not find complete text node.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $processor = new WP_HTML_Tag_Processor( 'test< /A>' );
+ $processor->next_token();
+ $this->assertSame( '#text', $processor->get_token_type(), 'Did not find text node.' );
+ $this->assertSame( 'test< /A>', $processor->get_modifiable_text(), 'Did not find complete text node.' );
</ins><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>