aria-api

access ARIA information from JavaScript
git clone https://git.ce9e.org/aria-api.git

commit
d58b5b8dd41691598db31a26e49879fcb7ef88ce
parent
233ecd417add6de0975ae844b5fcb3017e6a7a54
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-06-22 19:59
name: rework whitespace

Diffstat

M lib/name.js 18 ++++++++++--------

1 files changed, 10 insertions, 8 deletions


diff --git a/lib/name.js b/lib/name.js

@@ -2,9 +2,15 @@ const constants = require('./constants.js');
    2     2 const atree = require('./atree.js');
    3     3 const query = require('./query.js');
    4     4 
   -1     5 const addSpaces = function(text, el, pseudoSelector) {
   -1     6 	// https://github.com/w3c/accname/issues/3
   -1     7 	const styles = window.getComputedStyle(el, pseudoSelector);
   -1     8 	const inline = styles.display === 'inline';
   -1     9 	return inline ? text : ` ${text} `;
   -1    10 };
   -1    11 
    5    12 const getPseudoContent = function(el, pseudoSelector) {
    6    13 	const styles = window.getComputedStyle(el, pseudoSelector);
    7    -1 	const inline = styles.display.startsWith('inline');
    8    14 	let tail = styles.getPropertyValue('content').trim();
    9    15 	let ret = [];
   10    16 
@@ -29,7 +35,7 @@ const getPseudoContent = function(el, pseudoSelector) {
   29    35 		tail = tail.slice(match[0].length).trim();
   30    36 	}
   31    37 
   32    -1 	return inline ? ret.join('') : ` ${ret.join('')} `;
   -1    38 	return addSpaces(ret.join(''), el, pseudoSelector);
   33    39 };
   34    40 
   35    41 const getContent = function(root, visited) {
@@ -43,12 +49,8 @@ const getContent = function(root, visited) {
   43    49 		} else if (node.nodeType === node.ELEMENT_NODE) {
   44    50 			if (node.tagName.toLowerCase() === 'br') {
   45    51 				ret += '\n';
   46    -1 			} else if (window.getComputedStyle(node).display.substr(0, 6) === 'inline' &&
   47    -1 					node.tagName.toLowerCase() !== 'input' &&
   48    -1 					node.tagName.toLowerCase() !== 'img') {  // https://github.com/w3c/accname/issues/3
   49    -1 				ret += getName(node, true, visited);
   50    52 			} else {
   51    -1 				ret += ' ' + getName(node, true, visited) + ' ';
   -1    53 				ret += getName(node, true, visited);
   52    54 			}
   53    55 		}
   54    56 	}
@@ -178,7 +180,7 @@ const getName = function(el, recursive, visited, directReference) {
  178   180 
  179   181 	const before = getPseudoContent(el, ':before');
  180   182 	const after = getPseudoContent(el, ':after');
  181    -1 	return before + ret + after;
   -1   183 	return addSpaces(before + ret + after, el);
  182   184 };
  183   185 
  184   186 const getNameTrimmed = function(el) {