aria-api

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

commit
203f573c8eef5b361ab67ea8ad6eb3743ac344d6
parent
c0d7eef92b0fbb0a5e14ea1a18aa5d5b7d72101f
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-06-21 16:50
name: content fallback syntax

Diffstat

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

1 files changed, 25 insertions, 13 deletions


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

@@ -2,22 +2,34 @@ const constants = require('./constants.js');
    2     2 const atree = require('./atree.js');
    3     3 const query = require('./query.js');
    4     4 
    5    -1 const getPseudoContent = function(node, selector) {
    6    -1 	const styles = window.getComputedStyle(node, selector);
    7    -1 	const ret = styles.getPropertyValue('content');
    8    -1 	const inline = styles.display.substr(0, 6) === 'inline';
    9    -1 	if (!ret) {
   10    -1 		return '';
   11    -1 	}
   12    -1 	if (ret.substr(0, 1) !== '"') {
   13    -1 		return '';
   14    -1 	} else {
   15    -1 		if (inline) {
   16    -1 			return ret.slice(1, -1);
   -1     5 const getPseudoContent = function(el, pseudoSelector) {
   -1     6 	const styles = window.getComputedStyle(el, pseudoSelector);
   -1     7 	const inline = styles.display.startsWith('inline');
   -1     8 	let tail = styles.getPropertyValue('content').trim();
   -1     9 	let ret = [];
   -1    10 
   -1    11 	let match;
   -1    12 	while (tail.length) {
   -1    13 		if (match = tail.match(/^"([^"]*)"/)) {
   -1    14 			ret.push(match[1]);
   -1    15 		} else if (match = tail.match(/^([a-z-]+)\(([^)]*)\)/)) {
   -1    16 			if (match[1] === 'attr') {
   -1    17 				ret.push(el.getAttribute(match[2]) || '');
   -1    18 			}
   -1    19 		} else if (match = tail.match(/^([a-z-]+)/)) {
   -1    20 			if (match[1] === 'open-quote' || match[1] === 'close-quote') {
   -1    21 				ret.push('"');
   -1    22 			}
   -1    23 		} else if (match = tail.match(/^\//)) {
   -1    24 			ret = [];
   17    25 		} else {
   18    -1 			return ' ' + ret.slice(1, -1) + ' ';
   -1    26 			// invalid content, ignore
   -1    27 			return '';
   19    28 		}
   -1    29 		tail = tail.slice(match[0].length).trim();
   20    30 	}
   -1    31 
   -1    32 	return inline ? ret.join('') : ` ${ret.join('')} `;
   21    33 };
   22    34 
   23    35 const getContent = function(root, visited) {