-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(controller): add label activation support to FormController
Extends `FormController` to provide label activation via form associated custom elements via a shim where not supported (currently just Safari). Performing label activation is the responsibility of form associated elements. Helpers are provided to facilitate this, including `isActivationClick` and `dispatchActivationClick`. Note, any element that should perform an action via a click, could use these helpers to help distinguish external "activation" clicks. PiperOrigin-RevId: 495689270
- Loading branch information
1 parent
2ce167f
commit 4e3054b
Showing
6 changed files
with
510 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @license | ||
* Copyright 2022 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* FormAssociatedElement interface | ||
*/ | ||
export interface FormAssociatedElement extends HTMLElement {} | ||
|
||
declare var FormAssociatedElement: { | ||
new (): FormAssociatedElement; prototype: FormAssociatedElement; | ||
readonly formAssociated?: boolean; | ||
}; | ||
|
||
/** | ||
* Returns true if the element is a form associated custom element (FACE). | ||
*/ | ||
export function isFormAssociated(element: FormAssociatedElement) { | ||
return (element.constructor as typeof FormAssociatedElement).formAssociated; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.