Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,12 @@ private function _process_directives( string $html ) {
array_pop( $tag_stack );
}
} else {
if ( 0 !== count( $p->get_attribute_names_with_prefix( 'data-wp-each-child' ) ) ) {
$each_child_attrs = $p->get_attribute_names_with_prefix( 'data-wp-each-child' );
if ( null === $each_child_attrs ) {
continue;
}

if ( 0 !== count( $each_child_attrs ) ) {
/*
* If the tag has a `data-wp-each-child` directive, jump to its closer
* tag because those tags have already been processed.
Expand Down
25 changes: 25 additions & 0 deletions tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,31 @@ public static function data_html_with_unbalanced_tags() {
);
}

/**
* Tests that the `process_directives` handles self-closing BR tags without
* causing fatal errors and processes directives correctly.
*
* @ticket 63891
* @covers ::process_directives
*/
public function test_process_directives_handles_br_self_closing_tags_with_invalid_closers() {
$this->interactivity->state(
'myPlugin',
array(
'id' => 'some-id',
),
);

$html = '</br><div data-wp-bind--id="myPlugin::state.id">Content</div>';

$processed_html = $this->interactivity->process_directives( $html );

$p = new WP_HTML_Tag_Processor( $processed_html );
$p->next_tag( 'div' );

$this->assertSame( 'some-id', $p->get_attribute( 'id' ) );
}

/**
* Tests that the `process_directives` process the HTML outside a SVG tag.
*
Expand Down
Loading