-
Notifications
You must be signed in to change notification settings - Fork 107
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
Omit element node index in XPaths up to children of BODY #1790
Conversation
d7d0ae8
to
e840bdd
Compare
foreach ( $this->get_indexed_breadcrumbs() as $i => list( $tag_name, $index ) ) { | ||
if ( $i < 2 || ( 2 === $i && '/HTML/BODY' === $this->current_xpath ) ) { | ||
$this->current_xpath .= "/$tag_name"; | ||
} else { | ||
$this->current_xpath .= sprintf( '/*[%d][self::%s]', $index + 1, $tag_name ); | ||
} |
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.
All of the changes in this PR are a consequence of this change here.
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #1790 +/- ##
==========================================
- Coverage 57.43% 57.38% -0.05%
==========================================
Files 84 84
Lines 6508 6517 +9
==========================================
+ Hits 3738 3740 +2
- Misses 2770 2777 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
@westonruter Overall looks good to me, just one thought.
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.
@westonruter Approving, pending your code suggestion to expand the comment.
Summary
This is the last PR to address #1787.
Instead of an XPath like:
This PR now results in the first three levels of XPaths for elements in the body to not have the node index specified:
This will allow for variation in the content printed at
wp_body_open
from impacting the XPaths for the rest of the document.Note that nodes inside the
HEAD
will retain node indexes since there is no singular wrapper element inHEAD
.The changes located in
tests
directories are almost all attributable to a simple search-and-replace.Fixes #1787.