From 711796d17256a370a08ead0ecf65278630311efd Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Wed, 19 Apr 2017 19:53:42 +0000 Subject: [PATCH] Accessibility: Make Safari 10 + VoiceOver announce repeated, identical, `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 --- wp-includes/js/wp-a11y.js | 14 +++++++++++++- wp-includes/js/wp-a11y.min.js | 2 +- wp-includes/version.php | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/wp-includes/js/wp-a11y.js b/wp-includes/js/wp-a11y.js index 2507cbc2f4ed..7ccdd7540345 100644 --- a/wp-includes/js/wp-a11y.js +++ b/wp-includes/js/wp-a11y.js @@ -4,7 +4,8 @@ window.wp = window.wp || {}; 'use strict'; var $containerPolite, - $containerAssertive; + $containerAssertive, + previousMessage = ''; /** * Update the ARIA live notification area text node. @@ -23,6 +24,17 @@ window.wp = window.wp || {}; // Ensure only text is sent to screen readers. message = $( '

' ).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 ) { diff --git a/wp-includes/js/wp-a11y.min.js b/wp-includes/js/wp-a11y.min.js index c0c8929fe84f..3796ce189554 100644 --- a/wp-includes/js/wp-a11y.min.js +++ b/wp-includes/js/wp-a11y.min.js @@ -1 +1 @@ -window.wp=window.wp||{},function(a,b){"use strict";function c(a,c){e(),a=b("

").html(a).text(),g&&"assertive"===c?g.text(a):f&&f.text(a)}function d(a){a=a||"polite";var c=b("

",{id:"wp-a11y-speak-"+a,"aria-live":a,"aria-relevant":"additions text","aria-atomic":"true","class":"screen-reader-text wp-a11y-speak-region"});return b(document.body).append(c),c}function e(){b(".wp-a11y-speak-region").text("")}var f,g;b(document).ready(function(){f=b("#wp-a11y-speak-polite"),g=b("#wp-a11y-speak-assertive"),f.length||(f=d("polite")),g.length||(g=d("assertive"))}),a.a11y=a.a11y||{},a.a11y.speak=c}(window.wp,window.jQuery); \ No newline at end of file +window.wp=window.wp||{},function(a,b){"use strict";function c(a,c){e(),a=b("

").html(a).text(),h===a&&(a+="\xa0"),h=a,g&&"assertive"===c?g.text(a):f&&f.text(a)}function d(a){a=a||"polite";var c=b("

",{id:"wp-a11y-speak-"+a,"aria-live":a,"aria-relevant":"additions text","aria-atomic":"true","class":"screen-reader-text wp-a11y-speak-region"});return b(document.body).append(c),c}function e(){b(".wp-a11y-speak-region").text("")}var f,g,h="";b(document).ready(function(){f=b("#wp-a11y-speak-polite"),g=b("#wp-a11y-speak-assertive"),f.length||(f=d("polite")),g.length||(g=d("assertive"))}),a.a11y=a.a11y||{},a.a11y.speak=c}(window.wp,window.jQuery); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 85933eab86db..f43c161010c1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.