Skip to content

Commit 9eb22d2

Browse files
fix: add aria-disabled to disabled elements
1 parent 17d9659 commit 9eb22d2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Diff for: src/utils.ts

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ const observer = new MutationObserver((mutationsList: MutationRecord[]) => {
1010
if (target.constructor['formAssociated']) {
1111
const isDisabled = target.hasAttribute('disabled');
1212
target.toggleAttribute('internals-disabled', isDisabled);
13+
if (isDisabled) {
14+
target.setAttribute('aria-disabled', 'true');
15+
} else {
16+
target.removeAttribute('aria-disabled');
17+
}
1318
if (target.formDisabledCallback) {
1419
target.formDisabledCallback.apply(target, [target.hasAttribute('disabled')]);
1520
}

Diff for: test/ElementInternals.test.js

+3
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ describe('The ElementInternals polyfill', () => {
314314
el.disabled = true;
315315
await elementUpdated(el);
316316
expect(internals.willValidate).to.be.false;
317+
if (ElementInternals.isPolyfilled) {
318+
expect(el.getAttribute('aria-disabled')).to.equal('true');
319+
}
317320
});
318321

319322
it('will participate in forms', async () => {

0 commit comments

Comments
 (0)