aria-api

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

commit
69f6eeda6d58eead7cb1ff873e9593237fa40377
parent
f2f4e53766f6c257ea5c5d576cb4ce3b063904e7
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-11-01 12:29
fix: take text-transform into account

Diffstat

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

1 files changed, 10 insertions, 1 deletions


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

@@ -46,7 +46,16 @@ const getContent = function(root, ongoingLabelledBy, visited) {
   46    46 	for (let i = 0; i < children.length; i++) {
   47    47 		const node = children[i];
   48    48 		if (node.nodeType === node.TEXT_NODE) {
   49    -1 			ret += node.textContent;
   -1    49 			const styles = window.getComputedStyle(node.parentElement);
   -1    50 			if (styles.textTransform === 'uppercase') {
   -1    51 				ret += node.textContent.toUpperCase();
   -1    52 			} else if (styles.textTransform === 'lowercase') {
   -1    53 				ret += node.textContent.toLowerCase();
   -1    54 			} else if (styles.textTransform === 'capitalize') {
   -1    55 				ret += node.textContent.replace(/\b\w/g, c => c.toUpperCase());
   -1    56 			} else {
   -1    57 				ret += node.textContent;
   -1    58 			}
   50    59 		} else if (node.nodeType === node.ELEMENT_NODE) {
   51    60 			if (node.tagName.toLowerCase() === 'br') {
   52    61 				ret += '\n';