Skip to content

Commit 50031a4

Browse files
committed
fix(tre): map HTML role attribute instead of notional aria-role
1 parent 54e05a1 commit 50031a4

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

packages/transient-render-engine/src/tree/TNodeCtor.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,29 @@ function updateNodeIndexes(node: Mutable<TNodeImpl>, i: number) {
3030
const emptyAttrs = Object.freeze({});
3131
const emptyClasses = Object.freeze([]);
3232

33-
function findNativeRole(role: string): AccessibilityRole | undefined {
34-
if (role === 'img') {
33+
function findNativeRole(ariaRole: string): AccessibilityRole | undefined {
34+
if (ariaRole === 'img') {
3535
return 'image';
3636
}
37-
if (role === 'heading') {
37+
if (ariaRole === 'heading') {
3838
return 'header';
3939
}
40-
if (role === 'dialog') {
40+
if (ariaRole === 'dialog') {
4141
return 'alert';
4242
}
43-
if (role === 'presentation') {
43+
if (ariaRole === 'presentation') {
4444
return 'none';
4545
}
4646
if (
47-
role === 'button' ||
48-
role === 'switch' ||
49-
role === 'checkbox' ||
50-
role === 'radio' ||
51-
role === 'radiogroup' ||
52-
role === 'link' ||
53-
role === 'search'
47+
ariaRole === 'button' ||
48+
ariaRole === 'switch' ||
49+
ariaRole === 'checkbox' ||
50+
ariaRole === 'radio' ||
51+
ariaRole === 'radiogroup' ||
52+
ariaRole === 'link' ||
53+
ariaRole === 'search'
5454
) {
55-
return role;
55+
return ariaRole;
5656
}
5757
}
5858

@@ -139,8 +139,8 @@ const prototype: Omit<TNodeImpl, 'displayName' | 'type'> = {
139139
text: accessibilityProps
140140
});
141141
}
142-
if (this.attributes['aria-role']) {
143-
const role = this.attributes['aria-role'];
142+
if (this.attributes.role) {
143+
const role = this.attributes.role;
144144
const accessibilityRole = findNativeRole(role);
145145
if (accessibilityRole) {
146146
const accessibilityProps: AccessibilityProps = {

packages/transient-render-engine/src/tree/__tests__/TNode.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,10 @@ describe('TNode class', () => {
254254
foo: null
255255
};
256256
for (const [ariaRole, accessibleRole] of Object.entries(rolesMap)) {
257-
it(`should support aria-role='${ariaRole}' HTML attribute`, () => {
257+
it(`should support role='${ariaRole}' HTML attribute`, () => {
258258
const node = newTNode({
259259
domNode: new Element('div', {
260-
'aria-role': ariaRole
260+
role: ariaRole
261261
})
262262
});
263263
expect(node.getReactNativeProps()).toEqual(

0 commit comments

Comments
 (0)