Added inline script to cleanup dominant color CSS variable on image load#2448
Added inline script to cleanup dominant color CSS variable on image load#2448Dhruval-678 wants to merge 4 commits intoWordPress:trunkfrom
Conversation
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @dhruval6781, @Dogway. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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 Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #2448 +/- ##
==========================================
- Coverage 69.33% 69.28% -0.06%
==========================================
Files 90 90
Lines 7749 7755 +6
==========================================
Hits 5373 5373
- Misses 2376 2382 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| { capture: true }, | ||
| ); | ||
| JS; | ||
| wp_register_script( 'dominant-color-cleanup', false, array(), DOMINANT_COLOR_IMAGES_VERSION, true ); |
There was a problem hiding this comment.
| wp_register_script( 'dominant-color-cleanup', false, array(), DOMINANT_COLOR_IMAGES_VERSION, true ); | |
| wp_register_script( 'dominant-color-cleanup', false, array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion |
IMO we don’t need to update the script version here. Versioning isn’t really necessary, and we can just pass null instead.
This is similar to how scripts are registered in the View Transitions plugin.
WDYT @westonruter
There was a problem hiding this comment.
Correct. It is an inline script, so the version is not used.
There was a problem hiding this comment.
The sniff should be updated to not earn when null is used for a script with a false src, but that's out of scope here.
There was a problem hiding this comment.
@mukeshpanchal27
Requested changes has been applied.
Kindly have a look.
Summary
Fixes #2432
Changes
Added inline script to cleanup dominant color CSS variable on image load.
This script removes the --dominant-color CSS variable from images after they load,
preventing issues with dynamically loaded or lazily-loaded images.
Use of AI Tools
Clude code