Skip to content

Commit

Permalink
fix(list): fix role for list-item (#8767)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinayuangao authored Dec 4, 2017
1 parent 5210b3e commit 8f7c7cf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/demo-app/a11y/list/list-a11y.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h2> Seasoning </h2>
<p>Showing a non-interactive list of seasonings.</p>
<mat-list role="list">
<mat-list-item *ngFor="let item of items"> {{item}} </mat-list-item>
<mat-list-item role="listitem" *ngFor="let item of items"> {{item}} </mat-list-item>
</mat-list>
</section>

Expand All @@ -26,7 +26,7 @@ <h2>Messages</h2>
message subject, and content of the message.
</p>
<mat-list role="list">
<mat-list-item *ngFor="let message of messages">
<mat-list-item role="listitem" *ngFor="let message of messages">
<img mat-list-avatar [src]="message.image" [alt]="message.from">
<h3 mat-line> {{message.from}} </h3>
<p mat-line> {{message.subject}} </p>
Expand All @@ -39,8 +39,8 @@ <h3 mat-line> {{message.from}} </h3>
<section>
<h2>Seasoning</h2>
<p>Showing a non-interactive list of seasonings with dense style.</p>
<mat-list dense>
<mat-list-item *ngFor="let item of items"> {{item}} </mat-list-item>
<mat-list role="list" dense>
<mat-list-item role="listitem" *ngFor="let item of items"> {{item}} </mat-list-item>
</mat-list>
</section>

Expand All @@ -49,14 +49,14 @@ <h2>Folders and notes for mailbox </h2>
<p>Showing a list with two sections, "folders" and "notes".</p>
<mat-list role="list">
<h3 mat-subheader>Folders</h3>
<mat-list-item *ngFor="let folder of folders">
<mat-list-item role="listitem" *ngFor="let folder of folders">
<mat-icon mat-list-icon>folder</mat-icon>
<h4 mat-line>{{folder.name}}</h4>
<p mat-line class="demo-secondary-text"> {{folder.updated}} </p>
</mat-list-item>
<mat-divider></mat-divider>
<h3 mat-subheader>Notes</h3>
<mat-list-item *ngFor="let note of notes">
<mat-list-item role="listitem" *ngFor="let note of notes">
<mat-icon mat-list-icgon>note</mat-icon>
<h4 mat-line>{{note.name}}</h4>
<p mat-line class="demo-secondary-text"> {{note.updated}} </p>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/list/list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ describe('MatList', () => {

let list = fixture.debugElement.children[0];
let listItem = fixture.debugElement.children[0].query(By.css('mat-list-item'));
expect(list.nativeElement.getAttribute('role')).toBeNull();
expect(listItem.nativeElement.getAttribute('role')).toBe('listitem');
expect(list.nativeElement.getAttribute('role')).toBeNull('Expect mat-list no role');
expect(listItem.nativeElement.getAttribute('role')).toBeNull('Expect mat-list-item no role');
});

it('should not show ripples for non-nav lists', () => {
Expand Down
1 change: 0 additions & 1 deletion src/lib/list/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export class MatListSubheaderCssMatStyler {}
selector: 'mat-list-item, a[mat-list-item]',
exportAs: 'matListItem',
host: {
'role': 'listitem',
'class': 'mat-list-item',
'(focus)': '_handleFocus()',
'(blur)': '_handleBlur()',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<mat-list role="list">
<mat-list-item>Item 1</mat-list-item>
<mat-list-item>Item 2</mat-list-item>
<mat-list-item>Item 3</mat-list-item>
<mat-list-item role="listitem">Item 1</mat-list-item>
<mat-list-item role="listitem">Item 2</mat-list-item>
<mat-list-item role="listitem">Item 3</mat-list-item>
</mat-list>

0 comments on commit 8f7c7cf

Please sign in to comment.