Skip to content

Commit 46e9abd

Browse files
qw-inbeefancohen
authored andcommitted
Handle the type={truthy} case in jsx
1 parent c538d35 commit 46e9abd

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

__tests__/src/util/implicitRoles/input-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@ describe('isAbstractRole', () => {
2929
it('works for the default case', () => {
3030
expect(getImplicitRoleForInput([JSXAttributeMock('type', '')])).toBe('textbox');
3131
});
32+
it('works for the true case', () => {
33+
expect(getImplicitRoleForInput([JSXAttributeMock('type', true)])).toBe('textbox');
34+
});
3235
});

__tests__/src/util/implicitRoles/menuitem-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ describe('isAbstractRole', () => {
1616
it('works for non-toolbars', () => {
1717
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', '')])).toBe('');
1818
});
19+
it('works for the true case', () => {
20+
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', true)])).toBe('');
21+
});
1922
});

src/util/implicitRoles/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function getImplicitRoleForInput(attributes) {
99
if (type) {
1010
const value = getLiteralPropValue(type) || '';
1111

12-
switch (value.toUpperCase()) {
12+
switch (typeof value === 'string' && value.toUpperCase()) {
1313
case 'BUTTON':
1414
case 'IMAGE':
1515
case 'RESET':

src/util/implicitRoles/menuitem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function getImplicitRoleForMenuitem(attributes) {
99
if (type) {
1010
const value = getLiteralPropValue(type) || '';
1111

12-
switch (value.toUpperCase()) {
12+
switch (typeof value === 'string' && value.toUpperCase()) {
1313
case 'COMMAND':
1414
return 'menuitem';
1515
case 'CHECKBOX':

0 commit comments

Comments
 (0)