Repository navigation
Conversation
…nvalid, and add test coverage
|
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. |
| * @return string Modified CSS with the actual animation duration in seconds. | ||
| */ | ||
| function plvt_inject_animation_duration( string $css, int $animation_duration ): string { | ||
| if ( $animation_duration <= 0 ) { |
There was a problem hiding this comment.
This is called with abs_int in https://github.com/WordPress/performance/pull/2706/changes#diff-1c421c546ad4335a5b5233d0dbb71cd84a39fb2049233e0b0e96241e0e58288aR319, but a guard may still be worthwhile in case others call the function incorrectly.
Wouldn't 0 be a valid value here?
The docblock seems inaccurate, the default is supposed to be 400 ms (settings.php:69), maybe we should fix that as well?
There was a problem hiding this comment.
Thanks for the great feedback! You are completely right on all points:
- Allow
0msas valid duration: Updated the check to strictly negative ($animation_duration < 0). A value of0is preserved and renders0s, which is valid CSS for instant transitions. - Default to
400ms& docblock fix: Updated the docblock and fallback value to400msto stay consistent withsettings.phpandtheme.php(as updated in Set default view transition duration to 400 for better alignment with browser default #2081). - Test coverage: Updated the unit test suite to verify that
0msproduces0s, and negative values default to400ms(0.4s). Also fixed the array index offset in the theme support unit test.
… 400ms, and update docblock
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #2706 +/- ##
==========================================
+ Coverage 70.50% 71.54% +1.03%
==========================================
Files 91 91
Lines 7869 7871 +2
==========================================
+ Hits 5548 5631 +83
+ Misses 2321 2240 -81
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for the great feedback! You are completely right on all points:
(Could a maintainer also please add the |
Summary
In the View Transitions plugin, the
plvt_inject_animation_duration()docblock explicitly states:However, the function was calculating
$seconds = $animation_duration / 1000;directly without verifying whether$animation_duration <= 0. If an invalid or zero duration was passed, it would generate a0sor negative duration rule in CSS instead of defaulting to the documented1000ms.This pull request:
plvt_inject_animation_duration()so that any duration<= 0defaults to1000ms.plvt_inject_animation_duration(),plvt_sanitize_view_transitions_theme_support(), andplvt_register_view_transition_animations().Type of Change
Checklist