aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.tooltip.js
diff options
context:
space:
mode:
authorDylan Barrell <dylan@barrell.com>2013-10-26 11:31:07 -0400
committerScott González <scott.gonzalez@gmail.com>2013-12-19 10:36:30 -0500
commitb9e438d07c370ac2d4b198048feb6b6922469f70 (patch)
tree053e2b484fb30ef9ac5ed0579a169edcc6ce2c80 /ui/jquery.ui.tooltip.js
parentc9042b960f5c7b83a52e3b5c79dab2fed03f27e1 (diff)
downloadjquery-ui-b9e438d07c370ac2d4b198048feb6b6922469f70.tar.gz
jquery-ui-b9e438d07c370ac2d4b198048feb6b6922469f70.zip
Tooltip: Improve accessibility by adding content to an aria-live div
Fixes #9610 Closes gh-1118
Diffstat (limited to 'ui/jquery.ui.tooltip.js')
-rw-r--r--ui/jquery.ui.tooltip.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js
index 9fde036a8..1ebe1a958 100644
--- a/ui/jquery.ui.tooltip.js
+++ b/ui/jquery.ui.tooltip.js
@@ -82,6 +82,16 @@ $.widget( "ui.tooltip", {
if ( this.options.disabled ) {
this._disable();
}
+
+ // Append the aria-live region so tooltips announce correctly
+ this.liveRegion = $( "<div>" )
+ .attr({
+ role: "log",
+ "aria-live": "assertive",
+ "aria-relevant": "additions"
+ })
+ .addClass( "ui-helper-hidden-accessible" )
+ .appendTo( this.document[ 0 ].body );
},
_setOption: function( key, value ) {
@@ -211,7 +221,7 @@ $.widget( "ui.tooltip", {
},
_open: function( event, target, content ) {
- var tooltip, events, delayedShow,
+ var tooltip, events, delayedShow, a11yContent,
positionOption = $.extend( {}, this.options.position );
if ( !content ) {
@@ -245,6 +255,18 @@ $.widget( "ui.tooltip", {
this._addDescribedBy( target, tooltip.attr( "id" ) );
tooltip.find( ".ui-tooltip-content" ).html( content );
+ // Support: Voiceover on OS X, JAWS on IE <= 9
+ // JAWS announces deletions even when aria-relevant="additions"
+ // Voiceover will sometimes re-read the entire log region's contents from the beginning
+ this.liveRegion.children().hide();
+ if ( content.clone ) {
+ a11yContent = content.clone();
+ a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
+ } else {
+ a11yContent = content;
+ }
+ $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion );
+
function position( event ) {
positionOption.of = event;
if ( tooltip.is( ":hidden" ) ) {
@@ -394,6 +416,7 @@ $.widget( "ui.tooltip", {
element.removeData( "ui-tooltip-title" );
}
});
+ this.liveRegion.remove();
}
});