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: Add debug notice for SSR #6413
base: trunk
Are you sure you want to change the base?
Interactivity API: Add debug notice for SSR #6413
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
225334a
to
24199ab
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an annotation that I believe is the preferred way to implement these tests:
/**
* @expectedIncorrectUsage WP_Interactivity_API::process_directives_args
*/
@@ -639,7 +660,8 @@ public function test_process_directives_changes_html_if_contains_svgs() { | |||
</header> | |||
'; | |||
$processed_html = $this->interactivity->process_directives( $html ); | |||
$p = new WP_HTML_Tag_Processor( $processed_html ); | |||
$this->setExpectedIncorrectUsage( 'WP_Interactivity_API::process_directives_args' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is available as an annotation. Add this to the tests that are expected to fail and all the changes to implement this tracking can be removed:
* @expectedIncorrectUsage WP_Interactivity_API::process_directives_args
src/wp-includes/interactivity-api/class-wp-interactivity-api.php
Outdated
Show resolved
Hide resolved
src/wp-includes/interactivity-api/class-wp-interactivity-api.php
Outdated
Show resolved
Hide resolved
32fa2d8
to
5758d38
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few notes but generally I think this is in a good place. I think the messages could be improved to be a bit more brief. I also think it might be helpful to include the interactivity namespace so that it's easier to locate the problem if there are many different interactive regions, what do you think?
For SVG/MATH:
Interactivity directives were detected on an incompatible %s tag when processing {{ namespace }}. These directives will be ignored.
For unbalanced (this is always due to a start tag without an end tag, right?):
Interactivity directives failed to process in {{ namespace }} due to a missing %s end tag.
src/wp-includes/interactivity-api/class-wp-interactivity-api.php
Outdated
Show resolved
Hide resolved
src/wp-includes/interactivity-api/class-wp-interactivity-api.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the messages could be a bit more brief (#6413 (review)) but this is working well generally. Thanks!
Done in 4b78690 |
Trac ticket: https://core.trac.wordpress.org/ticket/61044
This PR aims to improve the developer experience of the Interactivity API server directives processing.
Right now, the SSR won't work if there is any directive inside a SVG or MATHML tag. Or the HTML is unbalanced (there is some closer tag missing).
This PR adds a warning in those cases, if the developer is in debug mode.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.