<!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>[57835] trunk: Interactivity API: Prevent warning when using a bind directive with a short attribute name.</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/57835">57835</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/57835","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>swissspidy</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-03-14 15:28:12 +0000 (Thu, 14 Mar 2024)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Interactivity API: Prevent warning when using a bind directive with a short attribute name.

Adds new tests and improves existing ones by using `assertSame` to do type comparison as well.

Props jonsurrell, cbravobernal, swissspidy, gziolo.
Fixes <a href="https://core.trac.wordpress.org/ticket/60758">#60758</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesinteractivityapiclasswpinteractivityapiphp">trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api.php</a></li>
<li><a href="#trunktestsphpunittestsinteractivityapiwpInteractivityAPIwpbindphp">trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesinteractivityapiclasswpinteractivityapiphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api.php    2024-03-14 15:10:55 UTC (rev 57834)
+++ trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api.php      2024-03-14 15:28:12 UTC (rev 57835)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -591,7 +591,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                $attribute_value = $p->get_attribute( $attribute_name );
</span><span class="cx" style="display: block; padding: 0 10px">                                $result          = $this->evaluate( $attribute_value, end( $namespace_stack ), end( $context_stack ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                if ( null !== $result && ( false !== $result || '-' === $bound_attribute[4] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if (
+                                       null !== $result &&
+                                       (
+                                               false !== $result ||
+                                               ( strlen( $bound_attribute ) > 5 && '-' === $bound_attribute[4] )
+                                       )
+                               ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         /*
</span><span class="cx" style="display: block; padding: 0 10px">                                         * If the result of the evaluation is a boolean and the attribute is
</span><span class="cx" style="display: block; padding: 0 10px">                                         * `aria-` or `data-, convert it to a string "true" or "false". It
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -599,7 +605,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                         * replicate what Preact will later do in the client:
</span><span class="cx" style="display: block; padding: 0 10px">                                         * https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L131C24-L136
</span><span class="cx" style="display: block; padding: 0 10px">                                         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        if ( is_bool( $result ) && '-' === $bound_attribute[4] ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 if (
+                                               is_bool( $result ) &&
+                                               ( strlen( $bound_attribute ) > 5 && '-' === $bound_attribute[4] )
+                                       ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                                 $result = $result ? 'true' : 'false';
</span><span class="cx" style="display: block; padding: 0 10px">                                        }
</span><span class="cx" style="display: block; padding: 0 10px">                                        $p->set_attribute( $bound_attribute, $result );
</span></span></pre></div>
<a id="trunktestsphpunittestsinteractivityapiwpInteractivityAPIwpbindphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php        2024-03-14 15:10:55 UTC (rev 57834)
+++ trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php  2024-03-14 15:28:12 UTC (rev 57835)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -33,6 +33,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'null'        => null,
</span><span class="cx" style="display: block; padding: 0 10px">                                'trueString'  => 'true',
</span><span class="cx" style="display: block; padding: 0 10px">                                'falseString' => 'false',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'trueValue'   => true,
+                               'falseValue'  => 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">@@ -60,7 +62,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_sets_attribute() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html    = '<div data-wp-bind--id="myPlugin::state.id">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'some-id', $p->get_attribute( 'id' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'some-id', $p->get_attribute( 'id' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -73,7 +75,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_replaces_attribute() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html    = '<div id="other-id" data-wp-bind--id="myPlugin::state.id">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'some-id', $p->get_attribute( 'id' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'some-id', $p->get_attribute( 'id' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -86,7 +88,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_sets_number_value() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html    = '<img data-wp-bind--width="myPlugin::state.width">';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( '100', $p->get_attribute( 'width' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( '100', $p->get_attribute( 'width' ) );
</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">@@ -99,8 +101,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_sets_true_string() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div data-wp-bind--id="myPlugin::state.trueString">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'true', $p->get_attribute( 'id' ) );
-               $this->assertEquals( '<div id="true" data-wp-bind--id="myPlugin::state.trueString">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'true', $p->get_attribute( 'id' ) );
+               $this->assertSame( '<div id="true" data-wp-bind--id="myPlugin::state.trueString">Text</div>', $new_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">@@ -113,8 +115,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_sets_false_string() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div data-wp-bind--id="myPlugin::state.falseString">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'false', $p->get_attribute( 'id' ) );
-               $this->assertEquals( '<div id="false" data-wp-bind--id="myPlugin::state.falseString">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'false', $p->get_attribute( 'id' ) );
+               $this->assertSame( '<div id="false" data-wp-bind--id="myPlugin::state.falseString">Text</div>', $new_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">@@ -127,7 +129,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_ignores_empty_bound_attribute() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = '<div data-wp-bind="myPlugin::state.id">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                $new_html = $this->interactivity->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $html, $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $html, $new_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">@@ -141,7 +143,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_doesnt_do_anything_on_non_existent_references() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = '<div data-wp-bind--id="myPlugin::state.nonExistengKey">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                $new_html = $this->interactivity->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $html, $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $html, $new_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">@@ -154,7 +156,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_ignores_empty_value() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = '<div data-wp-bind--id="">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                $new_html = $this->interactivity->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $html, $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $html, $new_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">@@ -167,7 +169,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_ignores_without_value() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = '<div data-wp-bind--id>Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                $new_html = $this->interactivity->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $html, $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $html, $new_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">@@ -181,7 +183,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_works_with_multiple_same_directives() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html    = '<div data-wp-bind--id="myPlugin::state.id" data-wp-bind--id="myPlugin::state.id">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'some-id', $p->get_attribute( 'id' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'some-id', $p->get_attribute( 'id' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -195,8 +197,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_works_with_multiple_different_directives() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html    = '<img data-wp-bind--id="myPlugin::state.id" data-wp-bind--width="myPlugin::state.width">';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'some-id', $p->get_attribute( 'id' ) );
-               $this->assertEquals( '100', $p->get_attribute( 'width' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'some-id', $p->get_attribute( 'id' ) );
+               $this->assertSame( '100', $p->get_attribute( 'width' ) );
</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">@@ -210,7 +212,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div data-wp-bind--hidden="myPlugin::!state.isOpen">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( $p->get_attribute( 'hidden' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( '<div hidden data-wp-bind--hidden="myPlugin::!state.isOpen">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( '<div hidden data-wp-bind--hidden="myPlugin::!state.isOpen">Text</div>', $new_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">@@ -225,7 +227,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div hidden="true" data-wp-bind--hidden="myPlugin::!state.isOpen">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( $p->get_attribute( 'hidden' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( '<div hidden data-wp-bind--hidden="myPlugin::!state.isOpen">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( '<div hidden data-wp-bind--hidden="myPlugin::!state.isOpen">Text</div>', $new_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">@@ -240,12 +242,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div data-wp-bind--hidden="myPlugin::state.isOpen">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNull( $p->get_attribute( 'hidden' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $html, $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $html, $new_html );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div data-wp-bind--hidden="myPlugin::state.null">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNull( $p->get_attribute( 'hidden' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $html, $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $html, $new_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">@@ -277,13 +279,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_adds_value_if_true_in_aria_or_data_attributes() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div data-wp-bind--aria-hidden="myPlugin::!state.isOpen">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'true', $p->get_attribute( 'aria-hidden' ) );
-               $this->assertEquals( '<div aria-hidden="true" data-wp-bind--aria-hidden="myPlugin::!state.isOpen">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'true', $p->get_attribute( 'aria-hidden' ) );
+               $this->assertSame( '<div aria-hidden="true" data-wp-bind--aria-hidden="myPlugin::!state.isOpen">Text</div>', $new_html );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div data-wp-bind--data-is-closed="myPlugin::!state.isOpen">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'true', $p->get_attribute( 'data-is-closed' ) );
-               $this->assertEquals( '<div data-is-closed="true" data-wp-bind--data-is-closed="myPlugin::!state.isOpen">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'true', $p->get_attribute( 'data-is-closed' ) );
+               $this->assertSame( '<div data-is-closed="true" data-wp-bind--data-is-closed="myPlugin::!state.isOpen">Text</div>', $new_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">@@ -297,15 +299,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_replaces_value_if_true_in_aria_or_data_attributes() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div aria-hidden="false" data-wp-bind--aria-hidden="myPlugin::!state.isOpen">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'true', $p->get_attribute( 'aria-hidden' ) );
-               $this->assertEquals( '<div aria-hidden="true" data-wp-bind--aria-hidden="myPlugin::!state.isOpen">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'true', $p->get_attribute( 'aria-hidden' ) );
+               $this->assertSame( '<div aria-hidden="true" data-wp-bind--aria-hidden="myPlugin::!state.isOpen">Text</div>', $new_html );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = '<div data-is-closed="false" data-wp-bind--data-is-closed="myPlugin::!state.isOpen">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                $new_html = $this->interactivity->process_directives( $html );
</span><span class="cx" style="display: block; padding: 0 10px">                $p        = new WP_HTML_Tag_Processor( $new_html );
</span><span class="cx" style="display: block; padding: 0 10px">                $p->next_tag();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'true', $p->get_attribute( 'data-is-closed' ) );
-               $this->assertEquals( '<div data-is-closed="true" data-wp-bind--data-is-closed="myPlugin::!state.isOpen">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'true', $p->get_attribute( 'data-is-closed' ) );
+               $this->assertSame( '<div data-is-closed="true" data-wp-bind--data-is-closed="myPlugin::!state.isOpen">Text</div>', $new_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">@@ -319,13 +321,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_adds_value_if_false_in_aria_or_data_attributes() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div data-wp-bind--aria-hidden="myPlugin::state.isOpen">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'false', $p->get_attribute( 'aria-hidden' ) );
-               $this->assertEquals( '<div aria-hidden="false" data-wp-bind--aria-hidden="myPlugin::state.isOpen">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'false', $p->get_attribute( 'aria-hidden' ) );
+               $this->assertSame( '<div aria-hidden="false" data-wp-bind--aria-hidden="myPlugin::state.isOpen">Text</div>', $new_html );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div data-wp-bind--data-is-closed="myPlugin::state.isOpen">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'false', $p->get_attribute( 'data-is-closed' ) );
-               $this->assertEquals( '<div data-is-closed="false" data-wp-bind--data-is-closed="myPlugin::state.isOpen">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'false', $p->get_attribute( 'data-is-closed' ) );
+               $this->assertSame( '<div data-is-closed="false" data-wp-bind--data-is-closed="myPlugin::state.isOpen">Text</div>', $new_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">@@ -339,13 +341,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_replaces_value_if_false_in_aria_or_data_attributes() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div aria-hidden="true" data-wp-bind--aria-hidden="myPlugin::state.isOpen">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'false', $p->get_attribute( 'aria-hidden' ) );
-               $this->assertEquals( '<div aria-hidden="false" data-wp-bind--aria-hidden="myPlugin::state.isOpen">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'false', $p->get_attribute( 'aria-hidden' ) );
+               $this->assertSame( '<div aria-hidden="false" data-wp-bind--aria-hidden="myPlugin::state.isOpen">Text</div>', $new_html );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $html               = '<div data-is-closed="true" data-wp-bind--data-is-closed="myPlugin::state.isOpen">Text</div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p, $new_html) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'false', $p->get_attribute( 'data-is-closed' ) );
-               $this->assertEquals( '<div data-is-closed="false" data-wp-bind--data-is-closed="myPlugin::state.isOpen">Text</div>', $new_html );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'false', $p->get_attribute( 'data-is-closed' ) );
+               $this->assertSame( '<div data-is-closed="false" data-wp-bind--data-is-closed="myPlugin::state.isOpen">Text</div>', $new_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">@@ -375,8 +377,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_wp_bind_handles_nested_bindings() {
</span><span class="cx" style="display: block; padding: 0 10px">                $html    = '<div data-wp-bind--id="myPlugin::state.id"><img data-wp-bind--width="myPlugin::state.width"></div>';
</span><span class="cx" style="display: block; padding: 0 10px">                list($p) = $this->process_directives( $html );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'some-id', $p->get_attribute( 'id' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'some-id', $p->get_attribute( 'id' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $p->next_tag();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( '100', $p->get_attribute( 'width' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( '100', $p->get_attribute( 'width' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Tests handling bindings to boolean values.
+        *
+        * @ticket 60758
+        *
+        * @covers ::process_directives
+        */
+       public function test_wp_bind_handles_true_value() {
+               $html    = '<div data-wp-bind--id="myPlugin::state.trueValue"></div>';
+               list($p) = $this->process_directives( $html );
+               $this->assertSame( true, $p->get_attribute( 'id' ) );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>