Skip to content

Commit

Permalink
fix: add role to aom
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdwilliams committed Oct 11, 2021
1 parent d1dae8c commit 16a1f6c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/aom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export const aom: IAom = {
ariaValueMax: 'aria-valuemax',
ariaValueMin: 'aria-valuemin',
ariaValueNow: 'aria-valuenow',
ariaValueText: 'aria-valuetext'
ariaValueText: 'aria-valuetext',
role: 'role'
};

export const initAom = (ref: Element, internals: IElementInternals) => {
Expand Down
1 change: 1 addition & 0 deletions src/element-internals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class ElementInternals implements IElementInternals {
ariaValueMin: string;
ariaValueNow: string;
ariaValueText: string;
role: string;

states: CustomStateSet;

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface IAom {
ariaValueMin: string;
ariaValueNow: string;
ariaValueText: string;
role: string;
}

export interface IElementInternals extends IAom {
Expand Down
29 changes: 29 additions & 0 deletions test/polyfilledBrowsers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,34 @@ describe('ElementInternals polyfill behavior', () => {
expect(el.hasAttribute('internals-disabled')).to.be.false;
}
});

it('will reflect internals.role', async () => {
if (ElementInternals.isPolyfilled) {
el.internals.role = 'button';
await aTimeout();
expect(el.getAttribute('role')).to.equal('button');
}
});
});

describe('CustomStateSet', () => {
let el;
let states;

class StateSetElement extends HTMLElement {
constructor() {
super();

this.internals = this.attachInternals();
}
}

customElements.define('state-set-element', StateSetElement);

beforeEach(async () => {
el = await fixture(html`<state-set-element></state-set-element>`);
console.log({el})
states = el.internals.states;
});
});
});

0 comments on commit 16a1f6c

Please sign in to comment.