Skip to content

Commit

Permalink
fix: aria props should be configurable/enumerable (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson authored Aug 22, 2023
1 parent ea542a5 commit 3623be1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/@lwc/jest-preset/src/aria-reflection-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ for (const prop of ARIA_STRING_PROPS) {
this.setAttribute(attribute, value);
}
},
// These props in both WebKit and Chromium are configurable/enumerable. This allows overriding
// (Try `Object.getOwnPropertyDescriptor(Element.prototype, 'ariaLabel')` in either browser)
configurable: true,
enumerable: true,
});
}
}
6 changes: 6 additions & 0 deletions test/src/modules/smoke/aria/__tests__/aria.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,11 @@ describe('ARIA string reflection', () => {
div[prop] = null;
expect(div.getAttribute(attribute)).toBeNull();
});

it(`${prop} is configurable/enumerable`, () => {
const descriptor = Object.getOwnPropertyDescriptor(Element.prototype, prop);
expect(descriptor.configurable).toBe(true);
expect(descriptor.enumerable).toBe(true);
});
}
});

0 comments on commit 3623be1

Please sign in to comment.