Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactivity API: Fix directives in tags whose closing tag is not visited not working #6247

Closed
Changes from all 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 @@ -10,7 +10,7 @@
*
* @group interactivity-api
*/
class Tests_Interactivity_API_Functions extends WP_UnitTestCase {
class Tests_Interactivity_API_wpInteractivityAPIFunctions extends WP_UnitTestCase {
/**
* Set up.
*/
Expand Down Expand Up @@ -390,4 +390,31 @@ public function test_wp_interactivity_data_wp_context_with_json_flags() {
$this->assertEquals( 'data-wp-context=\'{"quot":"\u0022baz\u0022"}\'', wp_interactivity_data_wp_context( array( 'quot' => '"baz"' ) ) );
$this->assertEquals( 'data-wp-context=\'{"amp":"T\u0026T"}\'', wp_interactivity_data_wp_context( array( 'amp' => 'T&T' ) ) );
}

/**
* Tests that directives processing of tags that don't visit closer tag work.
*
* @ticket 60746
*
* @covers ::wp_interactivity_process_directives_of_interactive_blocks
*/
public function test_process_directives_in_tags_that_dont_visit_closer_tag() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this test be expanded (or another one added) which test that the absence of the new if condition does indeed cause breaking the whole server-side rendering processing as described?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I understand what you mean. The existing test already checks that the SSR doesn't break when there is an iframe. The same test was failing without the final solution.

By the way, I've reverted the if condition because it is solved by another PR as explained here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that there were wider breakages than just with a single element. So that's what I thought would be good to test.

register_block_type(
'test/custom-directive-block',
array(
'render_callback' => function () {
return '<iframe data-wp-interactive="nameSpace" ' . wp_interactivity_data_wp_context( array( 'text' => 'test' ) ) . ' data-wp-class--test="context.text" src="1"></iframe>';
},
'supports' => array(
'interactivity' => true,
),
)
);
$post_content = '<!-- wp:test/custom-directive-block /-->';
$processed_content = do_blocks( $post_content );
$processor = new WP_HTML_Tag_Processor( $processed_content );
$processor->next_tag( array( 'class_name' => 'test' ) );
unregister_block_type( 'test/custom-directive-block' );
$this->assertEquals( '1', $processor->get_attribute( 'src' ) );
}
}
Loading