Skip to content

Commit

Permalink
Handle the type={truthy} case in jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
qw-in authored and beefancohen committed Oct 15, 2018
1 parent c538d35 commit 46e9abd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions __tests__/src/util/implicitRoles/input-test.js
Expand Up @@ -29,4 +29,7 @@ describe('isAbstractRole', () => {
it('works for the default case', () => {
expect(getImplicitRoleForInput([JSXAttributeMock('type', '')])).toBe('textbox');
});
it('works for the true case', () => {
expect(getImplicitRoleForInput([JSXAttributeMock('type', true)])).toBe('textbox');
});
});
3 changes: 3 additions & 0 deletions __tests__/src/util/implicitRoles/menuitem-test.js
Expand Up @@ -16,4 +16,7 @@ describe('isAbstractRole', () => {
it('works for non-toolbars', () => {
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', '')])).toBe('');
});
it('works for the true case', () => {
expect(getImplicitRoleForMenuitem([JSXAttributeMock('type', true)])).toBe('');
});
});
2 changes: 1 addition & 1 deletion src/util/implicitRoles/input.js
Expand Up @@ -9,7 +9,7 @@ export default function getImplicitRoleForInput(attributes) {
if (type) {
const value = getLiteralPropValue(type) || '';

switch (value.toUpperCase()) {
switch (typeof value === 'string' && value.toUpperCase()) {
case 'BUTTON':
case 'IMAGE':
case 'RESET':
Expand Down
2 changes: 1 addition & 1 deletion src/util/implicitRoles/menuitem.js
Expand Up @@ -9,7 +9,7 @@ export default function getImplicitRoleForMenuitem(attributes) {
if (type) {
const value = getLiteralPropValue(type) || '';

switch (value.toUpperCase()) {
switch (typeof value === 'string' && value.toUpperCase()) {
case 'COMMAND':
return 'menuitem';
case 'CHECKBOX':
Expand Down

0 comments on commit 46e9abd

Please sign in to comment.