UNPKG

@material/web

Version:
55 lines (54 loc) 1.59 kB
/** * @license * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { LitElement } from 'lit'; import { MixinBase, MixinReturn } from '../../labs/behaviors/mixin.js'; /** * Mixes in aria delegation for elements that delegate focus and aria to inner * shadow root elements. * * This mixin fixes invalid aria announcements with shadow roots, caused by * duplicate aria attributes on both the host and the inner shadow root element. * * Note: this mixin **does not yet support** ID reference attributes, such as * `aria-labelledby` or `aria-controls`. * * @example * ```ts * class MyButton extends mixinDelegatesAria(LitElement) { * static shadowRootOptions = {mode: 'open', delegatesFocus: true}; * * render() { * return html` * <button aria-label=${this.ariaLabel || nothing}> * <slot></slot> * </button> * `; * } * } * ``` * ```html * <my-button aria-label="Plus one">+1</my-button> * ``` * * Use `ARIAMixinStrict` for lit analyzer strict types, such as the "role" * attribute. * * @example * ```ts * return html` * <button role=${(this as ARIAMixinStrict).role || nothing}> * <slot></slot> * </button> * `; * ``` * * In the future, updates to the Accessibility Object Model (AOM) will provide * built-in aria delegation features that will replace this mixin. * * @param base The class to mix functionality into. * @return The provided class with aria delegation mixed in. */ export declare function mixinDelegatesAria<T extends MixinBase<LitElement>>(base: T): MixinReturn<T>;