code format tweaks

This commit is contained in:
Hakim El Hattab 2016-10-05 12:00:21 +02:00
parent 7e99626b14
commit 02f95f4de6

View File

@ -554,21 +554,36 @@
} }
/**
* Converts the given HTML element into a string of text
* that can be announced to a screen reader. Hidden
* elements are excluded.
*/
function getStatusText( node ) { function getStatusText( node ) {
var text = "";
if(node.nodeType === 3) { //text node var text = '';
// Text node
if( node.nodeType === 3 ) {
text += node.textContent; text += node.textContent;
}else if (node.nodeType === 1) { //element node }
// Element node
else if( node.nodeType === 1 ) {
var isAriaHidden = node.getAttribute( 'aria-hidden' ); var isAriaHidden = node.getAttribute( 'aria-hidden' );
var isDisplayHidden = window.getComputedStyle( node )['display'] === 'none'; var isDisplayHidden = window.getComputedStyle( node )['display'] === 'none';
if( isAriaHidden !== 'true' && !isDisplayHidden ) { if( isAriaHidden !== 'true' && !isDisplayHidden ) {
var children = node.childNodes;
for (var i = 0;i < children.length; i++) { toArray( node.childNodes ).forEach( function( child ) {
text += getStatusText(children[i]); text += getStatusText( child );
} } );
} }
} }
return text; return text;
} }
/** /**