mirror of
https://github.com/material-components/material-web.git
synced 2026-03-09 00:09:23 +08:00
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
23 lines
571 B
TypeScript
23 lines
571 B
TypeScript
/**
|
|
* @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;
|
|
}
|