Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/space/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { QueryHandler } from '../common/QueryHandler.js';
import { assert } from '../util/assert.js';
import { AsyncIterableUtil } from '../util/AsyncIterableUtil.js';
const isKnownAttribute = (attribute) => {
return ['name', 'role'].includes(attribute);
};
const normalizeValue = (value) => {
return value.replace(/ +/g, ' ').trim();
};
/**
* The selectors consist of an accessible name to query for and optionally
* further aria attributes on the form `[<attribute>=<value>]`.
* Currently, we only support the `name` and `role` attribute.
* The following examples showcase how the syntax works wrt. querying:
*
* - 'title[role="heading"]' queries for elements with name 'title' and role 'heading'.
* - '[role="image"]' queries for elements with role 'image' and any name.
* - 'label' queries for elements with name 'label' and any role.
* - '[name=""][role="button"]' queries for elements with no name and role 'button'.
*/
const ATTRIBUTE_REGEXP = /\[\s*(?<attribute>\w+)\s*=\s*(?<quote>"|')(?<value>\\.|.*?(?=\k<quote>))\k<quote>\s*\]/g;
const parseARIASelector = (selector) => {
const queryOptions = {};
const defaultName = selector.replace(ATTRIBUTE_REGEXP, (_, attribute, __, value) => {
attribute = attribute.trim();
assert(isKnownAttribute(attribute), `Unknown aria attribute "${attribute}" in selector`);
queryOptions[attribute] = normalizeValue(value);
return '';
});
if (defaultName && !queryOptions.name) {
queryOptions.name = normalizeValue(defaultName);
}
return queryOptions;
};
/**
* @internal
*/
export class ARIAQueryHandler extends QueryHandler {
static querySelector = async (node, selector, { ariaQuerySelector }) => {
return await ariaQuerySelector(node, selector);
};
static async *queryAll(element, selector) {
const { name, role } = parseARIASelector(selector);
yield* element.queryAXTree(name, role);
}
static queryOne = async (element, selector) => {
return ((await AsyncIterableUtil.first(this.queryAll(element, selector))) ?? null);
};
}
//# sourceMappingURL=AriaQueryHandler.js.map |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0046 ]-- |