Skip to content

Commit

Permalink
Accessibility: Make Safari 10 + VoiceOver announce repeated, identica…
Browse files Browse the repository at this point in the history
…l, `wp.a11y.speak()` messages.

Safari 10 + VoiceOver don't announce repeated, identical, strings sent to an 
`aria-live` region. Appending a `no-break space` to a repeated message string,
forces them to think the strings are different.

Fixes #36853.

Built from https://develop.svn.wordpress.org/trunk@40479


git-svn-id: http://core.svn.wordpress.org/trunk@40355 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
afercia committed Apr 19, 2017
1 parent 7977451 commit 711796d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion wp-includes/js/wp-a11y.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ window.wp = window.wp || {};
'use strict';

var $containerPolite,
$containerAssertive;
$containerAssertive,
previousMessage = '';

/**
* Update the ARIA live notification area text node.
Expand All @@ -23,6 +24,17 @@ window.wp = window.wp || {};
// Ensure only text is sent to screen readers.
message = $( '<p>' ).html( message ).text();

/*
* Safari 10+VoiceOver don't announce repeated, identical strings. We use
* a `no-break space` to force them to think identical strings are different.
* See ticket #36853.
*/
if ( previousMessage === message ) {
message = message + '\u00A0';
}

previousMessage = message;

if ( $containerAssertive && 'assertive' === ariaLive ) {
$containerAssertive.text( message );
} else if ( $containerPolite ) {
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/js/wp-a11y.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40478';
$wp_version = '4.8-alpha-40479';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit 711796d

Please sign in to comment.