summaryrefslogtreecommitdiffstatshomepage
path: root/src/js/_enqueues/lib/ajax-response.js
diff options
context:
space:
mode:
authorJoe Dolson <joedolson@git.wordpress.org>2024-06-21 18:15:50 +0000
committerJoe Dolson <joedolson@git.wordpress.org>2024-06-21 18:15:50 +0000
commita81e28817ccf2dbbc42155f680135650102361f2 (patch)
tree0e39d92cdfe0aa77f7ddb5365bc615169d417bcd /src/js/_enqueues/lib/ajax-response.js
parent933857e6f4ed4641770e58994ae966d0c9871a36 (diff)
downloadwordpress-a81e28817ccf2dbbc42155f680135650102361f2.tar.gz
wordpress-a81e28817ccf2dbbc42155f680135650102361f2.zip
Administration: A11y: Add `role="alert"` on JS injected admin notices.
Add the attribute `role="alert"` on 12 instances of admin notices that are injected into the DOM using JavaScript. The `role="alert"` attribute allows screen readers to recognize the addition to the DOM and announce the errors to users. Props afercia, cyrus11, rcreators, joedolson. Fixes #47111. git-svn-id: https://develop.svn.wordpress.org/trunk@58455 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src/js/_enqueues/lib/ajax-response.js')
-rw-r--r--src/js/_enqueues/lib/ajax-response.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/js/_enqueues/lib/ajax-response.js b/src/js/_enqueues/lib/ajax-response.js
index 3fd6ff0314..af59d8183a 100644
--- a/src/js/_enqueues/lib/ajax-response.js
+++ b/src/js/_enqueues/lib/ajax-response.js
@@ -53,10 +53,10 @@ window.wpAjax = jQuery.extend( {
parsed.responses.push( response );
} );
if ( err.length ) {
- re.html( '<div class="notice notice-error">' + err + '</div>' );
+ re.html( '<div class="notice notice-error" role="alert">' + err + '</div>' );
wp.a11y.speak( err );
} else if ( noticeMessage.length ) {
- re.html( '<div class="notice notice-success is-dismissible"><p>' + noticeMessage + '</p></div>');
+ re.html( '<div class="notice notice-success is-dismissible" role="alert"><p>' + noticeMessage + '</p></div>');
jQuery(document).trigger( 'wp-updates-notice-added' );
wp.a11y.speak( noticeMessage );
}
@@ -64,15 +64,15 @@ window.wpAjax = jQuery.extend( {
}
if ( isNaN( x ) ) {
wp.a11y.speak( x );
- return ! re.html( '<div class="notice notice-error"><p>' + x + '</p></div>' );
+ return ! re.html( '<div class="notice notice-error" role="alert"><p>' + x + '</p></div>' );
}
x = parseInt( x, 10 );
if ( -1 === x ) {
wp.a11y.speak( wpAjax.noPerm );
- return ! re.html( '<div class="notice notice-error"><p>' + wpAjax.noPerm + '</p></div>' );
+ return ! re.html( '<div class="notice notice-error" role="alert"><p>' + wpAjax.noPerm + '</p></div>' );
} else if ( 0 === x ) {
wp.a11y.speak( wpAjax.broken );
- return ! re.html( '<div class="notice notice-error"><p>' + wpAjax.broken + '</p></div>' );
+ return ! re.html( '<div class="notice notice-error" role="alert"><p>' + wpAjax.broken + '</p></div>' );
}
return true;
},