-
Notifications
You must be signed in to change notification settings - Fork 103
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
Fix logic for seeking during optimization loop to prevent emitting seek() notices #1376
Merged
+179
−20
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c7798ba
Only seek back to the current tag if a tag visitor seeked
westonruter 4a2466b
Add missing bookmark name to warning message
westonruter a60c5d0
Fix attribute order in tests now that seeking is not happening
westonruter 442d252
Add test to ensure tag visitation does not exceed seek limit
westonruter 89d5bcc
Update attribute order in embed-optimizer test due to not seeking
westonruter d406219
Account for visitors calling next_token() not just seek()
westonruter ca2a99b
Update attribute order in Image Prioritizer test after eliminating ex…
westonruter 1bb8bbc
Prepare 0.4.1 release of Optimization Detective
westonruter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,7 +262,6 @@ public function data_provider_test_od_optimize_template_output_buffer(): array { | |
'video' => array( | ||
'set_up' => function (): void { | ||
$slug = od_get_url_metrics_slug( od_get_normalized_query_vars() ); | ||
$sample_size = od_get_url_metrics_breakpoint_sample_size(); | ||
foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $viewport_width ) { | ||
OD_URL_Metrics_Post_Type::store_url_metric( | ||
$slug, | ||
|
@@ -309,6 +308,79 @@ public function data_provider_test_od_optimize_template_output_buffer(): array { | |
', | ||
), | ||
|
||
'many_images' => array( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😎 |
||
'set_up' => function (): void { | ||
$slug = od_get_url_metrics_slug( od_get_normalized_query_vars() ); | ||
foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $viewport_width ) { | ||
|
||
$elements = array(); | ||
for ( $i = 1; $i < WP_HTML_Tag_Processor::MAX_SEEK_OPS; $i++ ) { | ||
$elements[] = array( | ||
'xpath' => sprintf( '/*[1][self::HTML]/*[2][self::BODY]/*[%d][self::IMG]', $i ), | ||
'isLCP' => false, | ||
); | ||
} | ||
|
||
OD_URL_Metrics_Post_Type::store_url_metric( | ||
$slug, | ||
$this->get_validated_url_metric( | ||
$viewport_width, | ||
$elements | ||
) | ||
); | ||
} | ||
}, | ||
'buffer' => ' | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>...</title> | ||
</head> | ||
<body> | ||
' . | ||
join( | ||
"\n", | ||
call_user_func( | ||
static function () { | ||
$tags = array(); | ||
for ( $i = 1; $i < WP_HTML_Tag_Processor::MAX_SEEK_OPS + 1; $i++ ) { | ||
$tags[] = sprintf( '<img src="https://example.com/foo.jpg" alt="Foo" width="1200" height="800" loading="lazy">' ); | ||
} | ||
return $tags; | ||
} | ||
) | ||
) . | ||
' | ||
</body> | ||
</html> | ||
', | ||
'expected' => ' | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>...</title> | ||
</head> | ||
<body> | ||
' . | ||
join( | ||
"\n", | ||
call_user_func( | ||
static function () { | ||
$tags = array(); | ||
for ( $i = 1; $i < WP_HTML_Tag_Processor::MAX_SEEK_OPS + 1; $i++ ) { | ||
$tags[] = sprintf( '<img data-od-xpath="/*[1][self::HTML]/*[2][self::BODY]/*[%d][self::IMG]" src="https://example.com/foo.jpg" alt="Foo" width="1200" height="800" loading="lazy">', $i ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spiffy |
||
} | ||
return $tags; | ||
} | ||
) | ||
) . | ||
' | ||
<script type="module">/* import detect ... */</script> | ||
</body> | ||
</html> | ||
', | ||
), | ||
|
||
'rss-response' => array( | ||
'set_up' => static function (): void { | ||
ini_set( 'default_mimetype', 'application/rss+xml' ); // phpcs:ignore WordPress.PHP.IniSet.Risky | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nice!