Skip to content

Commit 1c79bc3

Browse files
committed
feat: add accessibilityRole="header" to headings elements (h1...h6)
Thanks to the new transient render engine features, it is now very easy to attach default accessibility props to HTMLElementModels.
1 parent 4ee1646 commit 1c79bc3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/render-html/src/__tests__/component.render-html.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,20 @@ describe('RenderHTML', () => {
141141
act(() => anchor.props.onPress?.({}));
142142
expect(onPress).toHaveBeenCalled();
143143
});
144+
it("should add accessibility role 'header' to headings", () => {
145+
for (const header of ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']) {
146+
const { getByTestId } = render(
147+
<RenderHTML
148+
source={{
149+
html: `<${header}>test</${header}>`
150+
}}
151+
debug={false}
152+
contentWidth={0}
153+
/>
154+
);
155+
expect(getByTestId(header).props.accessibilityRole).toBe('header');
156+
}
157+
});
144158
});
145159
describe('regarding customHTMLElementsModels prop', () => {
146160
it('should support changing block content model to mixed', () => {

0 commit comments

Comments
 (0)