-
Notifications
You must be signed in to change notification settings - Fork 3.1k
HTML API: Remove unused processor state context_node property #7861
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
HTML API: Remove unused processor state context_node property #7861
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. |
|
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. |
|
Committed with https://core.trac.wordpress.org/changeset/59463. |
|
Ah, thanks for that! I was actually briefly confused by this when reviewing #7348 but forgot to flag it 😊 |
| $context_node = new WP_HTML_Token( | ||
| 'context-node', | ||
| $processor->state->context_node[0], | ||
| 'BODY', |
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.
something seems off here: why are we hard-coding BODY as the context node? it seems like we missed this in line 301 when we added support for other contexts, whereas that line should have been updated to something like $...->context_node[0] but now we’re moving in the opposite direction…?
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 landed before the additional context support and I believe all these lines are now stale.
In this change, the <body> context was still hard-coded above. It moved out of the ->state->context_node and into this location, while remaining hard-coded.
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.
The relevant lines are now around here:
| $tag_name = $this->current_element->token->node_name; |
wordpress-develop/src/wp-includes/html-api/class-wp-html-processor.php
Lines 538 to 540 in 4b34369
| $fragment_processor->context_node = clone $this->current_element->token; | |
| $fragment_processor->context_node->bookmark_name = 'context-node'; | |
| $fragment_processor->context_node->on_destroy = null; |
The processor state
context_nodeproperty is unused and redundant. Remove it.The processor uses a
context_nodeproperty on itself.The
$stateproperty is private, so it should not be accessible to subclasses.The class itself is marked with
access privateso should also be unused.wordpress-develop/src/wp-includes/html-api/class-wp-html-processor-state.php
Lines 10 to 22 in 8cd0ec0
wordpress-develop/src/wp-includes/html-api/class-wp-html-processor.php
Lines 164 to 166 in 8cd0ec0
See #7348 (comment).
Trac ticket: https://core.trac.wordpress.org/ticket/62518
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.