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

Disambiguate XPaths for children of BODY with id, class, or role attributes #1797

Draft
wants to merge 10 commits into
base: trunk
Choose a base branch
from
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

# Improve highlighting for PHPStan stub files.
*.stub linguist-language=PHP

# Hide diffs for Optimization Detective snapshots.
plugins/*/tests/test-cases/*/expected.html linguist-generated=true

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
$elements[] = array_merge(
$element_data,
array(
'xpath' => "/HTML/BODY/DIV/*[{$i}][self::FIGURE]/*[1][self::DIV]",
'xpath' => "/HTML/BODY/DIV[@class='wp-site-blocks']/*[{$i}][self::FIGURE]/*[1][self::DIV]",
)
);
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
$test_case->populate_url_metrics(
array(
array(
'xpath' => '/HTML/BODY/DIV/*[1][self::FIGURE]/*[1][self::DIV]',
'xpath' => '/HTML/BODY/DIV[@class=\'wp-site-blocks\']/*[1][self::FIGURE]/*[1][self::DIV]',
'isLCP' => false,
'intersectionRatio' => 1,
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ),
),
array(
'xpath' => '/HTML/BODY/DIV/*[1][self::FIGURE]/*[1][self::DIV]/*[1][self::VIDEO]',
'xpath' => '/HTML/BODY/DIV[@class=\'wp-site-blocks\']/*[1][self::FIGURE]/*[1][self::DIV]/*[1][self::VIDEO]',
'isLCP' => false,
'intersectionRatio' => 1,
),
array(
'xpath' => '/HTML/BODY/DIV/*[2][self::FIGURE]/*[1][self::DIV]',
'xpath' => '/HTML/BODY/DIV[@class=\'wp-site-blocks\']/*[2][self::FIGURE]/*[1][self::DIV]',
'isLCP' => false,
'intersectionRatio' => 0,
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 654 ) ),
),
array(
'xpath' => '/HTML/BODY/DIV/*[2][self::FIGURE]/*[1][self::DIV]/*[1][self::FIGURE]/*[2][self::VIDEO]',
'xpath' => '/HTML/BODY/DIV[@class=\'wp-site-blocks\']/*[2][self::FIGURE]/*[1][self::DIV]/*[1][self::FIGURE]/*[2][self::VIDEO]',
'isLCP' => false,
'intersectionRatio' => 0,
),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$test_case->populate_url_metrics(
array(
array(
'xpath' => '/HTML/BODY/DIV/*[1][self::FIGURE]/*[1][self::DIV]',
'xpath' => '/HTML/BODY/DIV[@class=\'wp-site-blocks\']/*[1][self::FIGURE]/*[1][self::DIV]',
'isLCP' => false,
'intersectionRatio' => 0,
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$test_case->populate_url_metrics(
array(
array(
'xpath' => '/HTML/BODY/DIV/*[1][self::FIGURE]/*[1][self::DIV]',
'xpath' => '/HTML/BODY/DIV[@class=\'wp-site-blocks\']/*[1][self::FIGURE]/*[1][self::DIV]',
'isLCP' => true,
'intersectionRatio' => 1,
// Intentionally omitting resizedBoundingClientRect here to test behavior when data isn't supplied.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$test_case->populate_url_metrics(
array(
array(
'xpath' => '/HTML/BODY/DIV/*[1][self::FIGURE]/*[1][self::DIV]',
'xpath' => '/HTML/BODY/DIV[@class=\'wp-site-blocks\']/*[1][self::FIGURE]/*[1][self::DIV]',
'isLCP' => true,
'intersectionRatio' => 1,
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $i => $viewport_width ) {
$elements = array(
array(
'xpath' => '/HTML/BODY/DIV/*[1][self::FIGURE]/*[1][self::DIV]',
'xpath' => '/HTML/BODY/DIV[@class=\'wp-site-blocks\']/*[1][self::FIGURE]/*[1][self::DIV]',
'isLCP' => true,
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 + $i * 100 ) ),
),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$test_case->populate_url_metrics(
array(
array(
'xpath' => '/HTML/BODY/DIV/*[1][self::FIGURE]/*[1][self::DIV]',
'xpath' => '/HTML/BODY/DIV[@class=\'wp-site-blocks\']/*[1][self::FIGURE]/*[1][self::DIV]',
'isLCP' => false,
'intersectionRatio' => 0,
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$test_case->populate_url_metrics(
array(
array(
'xpath' => '/HTML/BODY/DIV/*[1][self::FIGURE]/*[1][self::DIV]',
'xpath' => '/HTML/BODY/DIV[@class=\'wp-site-blocks\']/*[1][self::FIGURE]/*[1][self::DIV]',
'isLCP' => true,
'intersectionRatio' => 1,
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ),
Expand Down
Loading
Loading