- ${this.renderStart()}
+
+
+ ${this.renderRipple()}
+ ${this.renderFocusRing()}
+
+
+
${this.renderBody()}
- ${this.renderEnd()}
- ${this.renderRipple()}
- ${this.renderFocusRing()}
-
+
`);
}
@@ -149,15 +136,29 @@ export class ListItemEl extends LitElement implements ListItem {
* @param content the child content of the list item.
*/
protected renderListItem(content: unknown) {
- const isAnchor = !!this.href;
- const tag = isAnchor ? literal`a` : literal`li`;
- const role = isAnchor || this.type === 'none' ? nothing : this.type;
+ const isAnchor = this.type === 'link';
+ let tag: StaticValue;
+ switch (this.type) {
+ case 'link':
+ tag = literal`a`;
+ break;
+ case 'button':
+ tag = literal`button`;
+ break;
+ default:
+ case 'text':
+ tag = literal`li`;
+ break;
+ }
+
+ // TODO(b/265339866): announce "button"/"link" inside of a list item. Until
+ // then all are "listitem" roles for correct announcement.
const target = isAnchor && !!this.target ? this.target : nothing;
return staticHtml`
<${tag}
id="item"
- tabindex="${this.disabled ? -1 : 0}"
- role=${role}
+ tabindex="${this.disabled && !isAnchor ? -1 : 0}"
+ role="listitem"
aria-selected=${(this as ARIAMixinStrict).ariaSelected || nothing}
aria-checked=${(this as ARIAMixinStrict).ariaChecked || nothing}
aria-expanded=${(this as ARIAMixinStrict).ariaExpanded || nothing}
@@ -166,10 +167,6 @@ export class ListItemEl extends LitElement implements ListItem {
href=${this.href || nothing}
target=${target}
@focus=${this.onFocus}
- @click=${this.onClick}
- @mouseenter=${this.onMouseenter}
- @mouseleave=${this.onMouseleave}
- @keydown=${this.onKeydown}
>${content}${tag}>
`;
}
@@ -178,6 +175,10 @@ export class ListItemEl extends LitElement implements ListItem {
* Handles rendering of the ripple element.
*/
protected renderRipple(): TemplateResult|typeof nothing {
+ if (this.type === 'text') {
+ return nothing;
+ }
+
return html`