Skip to content

Commit

Permalink
Change made to find_elements_by_semantic_locator_test.ts for accessib…
Browse files Browse the repository at this point in the history
…le name: removes the empty form element.

PiperOrigin-RevId: 643122843
  • Loading branch information
Googler authored and copybara-github committed Jun 18, 2024
1 parent f3db82f commit f97b9d6
Show file tree
Hide file tree
Showing 9 changed files with 544 additions and 383 deletions.
2 changes: 2 additions & 0 deletions docs/DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Developing Semantic Locators

<!-- go/semantic-locators-developing -->

## Get a local copy of the code

```bash
Expand Down
2 changes: 2 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# FAQ

<!-- go/semantic-locators-faq -->

## How can I handle internationalization/localization (i18n/L10n)?

Semantic locators don't yet have built-in support for tests with strong
Expand Down
2 changes: 2 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Features

<!-- go/semantic-locators-features -->

## Basic syntax

The following locator identifies an element anywhere on the page with a role of
Expand Down
2 changes: 2 additions & 0 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Tutorial

<!-- go/semantic-locators-tutorial -->

This doc is a step-by-step guide to writing (or auto-generating) semantic
locators.

Expand Down
15 changes: 8 additions & 7 deletions javascript/src/lib/role_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import {ConditionType, RoleSelector} from './types';

/** Role which has no native HTML equivalent. */
export type AriaOnlyRole = typeof ARIA_ONLY_ROLES_ARRAY[number];
export type AriaOnlyRole = (typeof ARIA_ONLY_ROLES_ARRAY)[number];

/** Type guard for AriaOnlyRole */
export function isAriaOnlyRole(role: string): role is AriaOnlyRole {
Expand All @@ -26,7 +26,7 @@ export function isImplicitRole(role: string): role is ImplicitRole {
return ROLE_MAP.hasOwnProperty(role);
}
/** Union type of all non-abstract ARIA roles. */
export type AriaRole = AriaOnlyRole|ImplicitRole;
export type AriaRole = AriaOnlyRole | ImplicitRole;

/** Type guard for AriaRole */
export function isAriaRole(role: string): role is AriaRole {
Expand All @@ -35,7 +35,7 @@ export function isAriaRole(role: string): role is AriaRole {

/** Map from role to a RoleSelector for finding that role. */
export type RoleMap = {
readonly[role in ImplicitRole]: RoleSelector;
readonly [role in ImplicitRole]: RoleSelector;
};

// clang-format off
Expand Down Expand Up @@ -88,7 +88,7 @@ export const CHILDREN_PRESENTATIONAL = [
'math',
'menuitemcheckbox',
'menuitemradio',
// 'option', // TODO(b/180594818) enforce for option
// 'option', // TODO(b/340325104) Investigate turning this back on.
'progressbar',
'radio',
'scrollbar',
Expand All @@ -98,14 +98,15 @@ export const CHILDREN_PRESENTATIONAL = [
'tab',
] as const;

type ChildrenPresentational = typeof CHILDREN_PRESENTATIONAL[number];
type ChildrenPresentational = (typeof CHILDREN_PRESENTATIONAL)[number];

/**
* Whether the given role has presentational children.
* https://www.w3.org/TR/wai-aria-practices/#children_presentational
*/
export function isChildrenPresentational(role: AriaRole):
role is ChildrenPresentational {
export function isChildrenPresentational(
role: AriaRole,
): role is ChildrenPresentational {
return CHILDREN_PRESENTATIONAL.includes(role as ChildrenPresentational);
}

Expand Down
Loading

0 comments on commit f97b9d6

Please sign in to comment.