Ticket #32600: 32600-alt.patch
File 32600-alt.patch, 1.8 KB (added by , 9 years ago) |
---|
-
src/wp-includes/js/wp-a11y.js
3 3 ( function ( wp, $ ) { 4 4 'use strict'; 5 5 6 var $container ;6 var $container, $body; 7 7 8 8 /** 9 9 * Update the ARIA live notification area text node. 10 10 * 11 11 * @since 4.2.0 12 * @since 4.3.0 Introduced the 'ariaLive' argument. 12 13 * 13 * @param {String} message 14 * @param {String} message The message to be announced by Assistive Technologies. 15 * @param {String} ariaLive Optional. The politeness level for aria-live. Possible values: 16 * polite or assertive. Default polite. 14 17 */ 15 function speak( message ) { 16 if ( $container ) { 18 function speak( message, ariaLive ) { 19 // Clear previous messages to allow repeated strings being read out. 20 $container.text( '' ); 21 22 ariaLive = ariaLive || 'polite'; 23 24 if ( $container.attr( 'aria-live' ) !== ariaLive ) { 25 $container.attr( 'aria-live', ariaLive ); 26 $body.append( $container ); 27 } 28 29 window.setTimeout( function() { 17 30 $container.text( message ); 18 } 31 }, 0 ); 19 32 } 20 33 21 34 /** … … 25 38 */ 26 39 $( document ).ready( function() { 27 40 $container = $( '#wp-a11y-speak' ); 41 $body = $( document.body ); 28 42 29 43 if ( ! $container.length ) { 30 44 $container = $( '<div>', { … … 31 45 id: 'wp-a11y-speak', 32 46 role: 'status', 33 47 'aria-live': 'polite', 34 'aria-relevant': 'a ll',48 'aria-relevant': 'additions text', 35 49 'aria-atomic': 'true', 36 50 'class': 'screen-reader-text' 37 } ); 38 39 $( document.body ).append( $container ); 51 }); 40 52 } 41 } );42 53 54 $body.append( $container ); 55 }); 56 43 57 wp.a11y = wp.a11y || {}; 44 58 wp.a11y.speak = speak; 45 59