From 90fc300ea96be7713dee63c6f7e311bf38b4837a Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 22 Aug 2017 23:04:10 +0200 Subject: [PATCH] fix(chips): invalid aria-selected value for non-selectable chip (#6544) --- src/lib/chips/chip.spec.ts | 9 ++------- src/lib/chips/chip.ts | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/lib/chips/chip.spec.ts b/src/lib/chips/chip.spec.ts index 2eb10502f1e..9565c178c56 100644 --- a/src/lib/chips/chip.spec.ts +++ b/src/lib/chips/chip.spec.ts @@ -194,13 +194,8 @@ describe('Chips', () => { expect(testComponent.chipSelect).not.toHaveBeenCalled(); }); - it('should have empty aria-selected', () => { - expect(chipNativeElement.getAttribute('aria-selected')).toBeFalsy(); - - testComponent.selectable = true; - fixture.detectChanges(); - - expect(chipNativeElement.getAttribute('aria-selected')).toBe('false'); + it('should not have the aria-selected attribute', () => { + expect(chipNativeElement.hasAttribute('aria-selected')).toBe(false); }); }); diff --git a/src/lib/chips/chip.ts b/src/lib/chips/chip.ts index 6bc349b53d9..a0ec3bc28c5 100644 --- a/src/lib/chips/chip.ts +++ b/src/lib/chips/chip.ts @@ -121,8 +121,8 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr /** Emitted when the chip is destroyed. */ @Output() destroy = new EventEmitter(); - get ariaSelected(): string { - return this.selectable ? this.selected.toString() : ''; + get ariaSelected(): string | null { + return this.selectable ? this.selected.toString() : null; } constructor(renderer: Renderer2, elementRef: ElementRef) {