Rocky_Mountain_Vending/.pnpm-store/v10/files/0e/b3638c6a62204651830ecd16a67fddee1f20164fc37a21488d7a95e9b7d986f289ae630019fc5f358568cf74ab4fb2593e0f006a5cda966889b54c70f1ce76
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

54 lines
No EOL
2.1 KiB
Text

/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { assert } from '../util/assert.js';
import { AsyncIterableUtil } from '../util/AsyncIterableUtil.js';
import { QueryHandler } from './QueryHandler.js';
const isKnownAttribute = (attribute) => {
return ['name', 'role'].includes(attribute);
};
/**
* 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) => {
if (selector.length > 10_000) {
throw new Error(`Selector ${selector} is too long`);
}
const queryOptions = {};
const defaultName = selector.replace(ATTRIBUTE_REGEXP, (_, attribute, __, value) => {
assert(isKnownAttribute(attribute), `Unknown aria attribute "${attribute}" in selector`);
queryOptions[attribute] = value;
return '';
});
if (defaultName && !queryOptions.name) {
queryOptions.name = 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