HTML API: Stop counting noop seek operations against the max seek count.#7399
HTML API: Stop counting noop seek operations against the max seek count.#7399dmsnell wants to merge 4 commits intoWordPress:trunkfrom
Conversation
Co-authored-by: Weston Ruter <westonruter@git.wordpress.org>
|
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. |
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. |
| $processor->set_bookmark( 'ping' ); | ||
| $processor->next_tag( 'li' ); | ||
| $processor->set_bookmark( 'pong' ); |
| $existing_bookmark = $this->bookmarks[ $bookmark_name ]; | ||
|
|
||
| if ( | ||
| $this->token_starts_at === $existing_bookmark->start && | ||
| $this->token_length === $existing_bookmark->length | ||
| ) { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
How will this impact (or not) WP_HTML_Processor::seek() since its actual bookmarks get prefixed with _?
wordpress-develop/src/wp-includes/html-api/class-wp-html-processor.php
Lines 5266 to 5275 in b071c28
There was a problem hiding this comment.
it shouldn't because by the time it calls this parent-class method, it has supplied the underscore.
There was a problem hiding this comment.
OK, right. By the way, what is the reasoning behind prefixing bookmarks with underscores in HTML Processor? In WordPress/performance#1546 I'm making use of WP_HTML_Processor when available, but in the logic that injects additional markup into the head and body, it needs to obtain the start position of the bookmark. For the HTML Processor version it has to prepend the _ which seems strange, although granted this is an internal API:
There was a problem hiding this comment.
the reason was to avoid any possible conflicts between bookmarks set by the HTML Processor itself, and the user-space code setting bookmarks. that is, any time someone calls WP_HTML_Processor::set_bookmark() it will be prefixed, but calls inside the processor to parent::set_bookmark() will be un-prefixed. it's a very basic namespacing mechanism.
…into html-api/stop-counting-void-seeks
|
Committed in r59812. |
Trac ticket: Core-62085
Weston's drafted commit message
HTML API: Stop counting no-op seek operations against the max seek count.
This allows
seek()to be freely called when the current cursor at the provided bookmark.Props dmsnell, jonsurrell, westonruter.
Fixes #62085.