diff --git a/src/wp-includes/interactivity-api/class-wp-interactivity-api.php b/src/wp-includes/interactivity-api/class-wp-interactivity-api.php index f2c66b07fcbb5..cf931108989a3 100644 --- a/src/wp-includes/interactivity-api/class-wp-interactivity-api.php +++ b/src/wp-includes/interactivity-api/class-wp-interactivity-api.php @@ -1026,7 +1026,7 @@ private function data_wp_bind_processor( WP_Interactivity_API_Directives_Process $entries = $this->get_directive_entries( $p, 'bind' ); foreach ( $entries as $entry ) { if ( empty( $entry['suffix'] ) || null !== $entry['unique_id'] ) { - return; + continue; } $result = $this->evaluate( $entry ); diff --git a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php index cd3f17c8ae254..02fc0d09293f7 100644 --- a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php +++ b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php @@ -134,6 +134,20 @@ public function test_wp_bind_ignores_empty_bound_attribute() { $this->assertSame( $html, $new_html ); } + /** + * Tests that `data-wp-bind` ignores directives with no suffix but still + * processes valid bind directives on the same element. + * + * @ticket 64518 + * + * @covers ::process_directives + */ + public function test_wp_bind_ignores_empty_suffix_but_processes_valid_binds() { + $html = '
Text
'; + list($p) = $this->process_directives( $html ); + $this->assertSame( 'some-id', $p->get_attribute( 'id' ) ); + } + /** * Tests that `data-wp-bind` does nothing when referencing non-existent * references. @@ -416,4 +430,18 @@ public function test_wp_bind_ignores_unique_ids() { $this->assertNull( $p->get_attribute( 'id' ) ); $this->assertNull( $p->get_attribute( 'id---unique-id' ) ); } + + /** + * Tests that `data-wp-bind` ignores directives with unique IDs but still + * processes valid bind directives on the same element. + * + * @ticket 64518 + * + * @covers ::process_directives + */ + public function test_wp_bind_ignores_unique_id_but_processes_valid_binds() { + $html = '
Text
'; + list($p) = $this->process_directives( $html ); + $this->assertSame( 'some-id', $p->get_attribute( 'id' ) ); + } }