Skip to content

Commit

Permalink
feat: add accessibilityRole="header" to headings elements (h1...h6)
Browse files Browse the repository at this point in the history
Thanks to the new transient render engine features, it is now very
easy to attach default accessibility props to HTMLElementModels.
  • Loading branch information
jsamr committed Sep 4, 2021
1 parent 4ee1646 commit 1c79bc3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/render-html/src/__tests__/component.render-html.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,20 @@ describe('RenderHTML', () => {
act(() => anchor.props.onPress?.({}));
expect(onPress).toHaveBeenCalled();
});
it("should add accessibility role 'header' to headings", () => {
for (const header of ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']) {
const { getByTestId } = render(
<RenderHTML
source={{
html: `<${header}>test</${header}>`
}}
debug={false}
contentWidth={0}
/>
);
expect(getByTestId(header).props.accessibilityRole).toBe('header');
}
});
});
describe('regarding customHTMLElementsModels prop', () => {
it('should support changing block content model to mixed', () => {
Expand Down

0 comments on commit 1c79bc3

Please sign in to comment.