@jsxtools/eslint-plugin-jsx-a11y
Version:
Static AST checker for accessibility rules on JSX elements for flat ESLint Config.
32 lines (29 loc) • 767 B
JavaScript
const jsxAstUtils = require('../module/jsx-ast-utils.cjs');
function getImplicitRoleForInput(attributes) {
const type = jsxAstUtils.getProp(attributes, "type");
if (type) {
const value = jsxAstUtils.getLiteralPropValue(type) || "";
switch (typeof value === "string" && value.toUpperCase()) {
case "BUTTON":
case "IMAGE":
case "RESET":
case "SUBMIT":
return "button";
case "CHECKBOX":
return "checkbox";
case "RADIO":
return "radio";
case "RANGE":
return "slider";
case "EMAIL":
case "PASSWORD":
case "SEARCH":
case "TEL":
case "URL":
default:
return "textbox";
}
}
return "textbox";
}
module.exports = getImplicitRoleForInput;