mirror of
https://github.com/material-components/material-web.git
synced 2024-11-10 20:11:57 +03:00
chore(decorators): update key types for ariaProperty
PiperOrigin-RevId: 460552893
This commit is contained in:
parent
0949b075e5
commit
42bf876fe1
@ -31,8 +31,8 @@ import {ReactiveElement} from 'lit';
|
||||
* @category Decorator
|
||||
* @ExportDecoratedItems
|
||||
*/
|
||||
export function ariaProperty(
|
||||
prototype: ReactiveElement, property: keyof ARIAMixin) {
|
||||
export function ariaProperty<E extends ReactiveElement, K extends keyof E&
|
||||
`aria${string}`>(prototype: E, property: K) {
|
||||
// Replace the ARIAMixin property with data-* attribute syncing instead of
|
||||
// using the native aria-* attribute reflection. This preserves the attribute
|
||||
// for SSR and avoids screenreader conflicts after delegating the attribute
|
||||
@ -75,9 +75,9 @@ export function ariaProperty(
|
||||
// tslint is failing here, but the types are correct (ARIAMixin
|
||||
// properties do not obfuscate with closure)
|
||||
// tslint:disable-next-line:no-dict-access-on-struct-type
|
||||
return this[property];
|
||||
return (this as E)[property];
|
||||
},
|
||||
set(this: ReactiveElement, value: string) {
|
||||
set(this: ReactiveElement, value: E[K]) {
|
||||
if (removingAttribute) {
|
||||
// Ignore this update, which is triggered below
|
||||
return;
|
||||
@ -88,7 +88,7 @@ export function ariaProperty(
|
||||
// tslint is failing here, but the types are correct (ARIAMixin
|
||||
// properties do not obfuscate with closure)
|
||||
// tslint:disable-next-line:no-dict-access-on-struct-type
|
||||
this[property] = value;
|
||||
(this as E)[property] = value;
|
||||
// Remove the `aria-*` attribute, which will call this setter again with
|
||||
// the incorrect value. Ignore these updates.
|
||||
removingAttribute = true;
|
||||
|
Loading…
Reference in New Issue
Block a user