mirror of
git://develop.git.wordpress.org/
synced 2025-04-05 04:33:18 +02:00
Plugins: Prevent ajaxComplete
listener from observing all events.
Add a conditional to prevent the `prefers-reduced-motion` `ajaxComplete` listener from observing events not occurring in the plugin installation screen. Improve handling of settings data test. The listener observing `ajaxComplete` in [56541] was intercepting all `ajaxComplete` events, creating potential for unexpected errors in unrelated functions. Props bplv, afercia, rudlinkon, hellofromTonya, huzaifaalmesbah, joedolson, jorbin. Reviewed by jorbin. Merges [57022] to the 6.4 branch. Fixes #59689. git-svn-id: https://develop.svn.wordpress.org/branches/6.4@57024 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
74d3772816
commit
dbb44d40a3
@ -2129,8 +2129,8 @@ $( function( $ ) {
|
||||
/**
|
||||
* Freeze animated plugin icons when reduced motion is enabled.
|
||||
*
|
||||
* When the user has enabled the 'prefers-reduced-motion' setting, this module
|
||||
* stops animations for all GIFs on the page with the class 'plugin-icon' or
|
||||
* When the user has enabled the 'prefers-reduced-motion' setting, this module
|
||||
* stops animations for all GIFs on the page with the class 'plugin-icon' or
|
||||
* plugin icon images in the update plugins table.
|
||||
*
|
||||
* @since 6.4.0
|
||||
@ -2156,7 +2156,7 @@ $( function( $ ) {
|
||||
var width = img.width;
|
||||
var height = img.height;
|
||||
var canvas = document.createElement( 'canvas' );
|
||||
|
||||
|
||||
// Set canvas dimensions.
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
@ -2219,23 +2219,27 @@ $( function( $ ) {
|
||||
|
||||
// Listen for jQuery AJAX events.
|
||||
( function( $ ) {
|
||||
$( document ).ajaxComplete( function( event, xhr, settings ) {
|
||||
// Check if this is the 'search-install-plugins' request.
|
||||
if ( settings.data && settings.data.includes( 'action=search-install-plugins' ) ) {
|
||||
// Recheck if the user prefers reduced motion.
|
||||
if ( window.matchMedia ) {
|
||||
var mediaQuery = window.matchMedia( '(prefers-reduced-motion: reduce)' );
|
||||
if ( mediaQuery.matches ) {
|
||||
pub.freezeAll();
|
||||
}
|
||||
} else {
|
||||
// Fallback for browsers that don't support matchMedia.
|
||||
if ( true === priv.pauseAll ) {
|
||||
pub.freezeAll();
|
||||
if ( window.pagenow === 'plugin-install' ) {
|
||||
// Only listen for ajaxComplete if this is the plugin-install.php page.
|
||||
$( document ).ajaxComplete( function( event, xhr, settings ) {
|
||||
|
||||
// Check if this is the 'search-install-plugins' request.
|
||||
if ( settings.data && typeof settings.data === 'string' && settings.data.includes( 'action=search-install-plugins' ) ) {
|
||||
// Recheck if the user prefers reduced motion.
|
||||
if ( window.matchMedia ) {
|
||||
var mediaQuery = window.matchMedia( '(prefers-reduced-motion: reduce)' );
|
||||
if ( mediaQuery.matches ) {
|
||||
pub.freezeAll();
|
||||
}
|
||||
} else {
|
||||
// Fallback for browsers that don't support matchMedia.
|
||||
if ( true === priv.pauseAll ) {
|
||||
pub.freezeAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
} )( jQuery );
|
||||
|
||||
// Expose public methods.
|
||||
|
Loading…
x
Reference in New Issue
Block a user