Skip to content

Commit

Permalink
fix(divider): update a11y semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook committed Mar 29, 2021
1 parent 861696b commit 46e6a12
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions packages/divider/src/Divider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
TemplateResult,
property,
SizedMixin,
PropertyValues,
} from '@spectrum-web-components/base';

import styles from './divider.css.js';
Expand All @@ -33,9 +34,22 @@ export class Divider extends SizedMixin(SpectrumElement, {
public vertical = false;

protected render(): TemplateResult {
if (this.vertical) return html``;
return html`
<hr />
`;
return html``;
}

protected firstUpdated(changed: PropertyValues<this>): void {
super.firstUpdated(changed);
this.setAttribute('role', 'separator');
}

protected updated(changed: PropertyValues<this>): void {
super.updated(changed);
if (changed.has('vertical')) {
if (this.vertical) {
this.setAttribute('aria-orientation', 'vertical');
} else {
this.removeAttribute('aria-orientation');
}
}
}
}

0 comments on commit 46e6a12

Please # to comment.