UNPKG

@jsxtools/eslint-plugin-jsx-a11y

Version:

Static AST checker for accessibility rules on JSX elements for flat ESLint Config.

32 lines (29 loc) 763 B
import { getProp, getLiteralPropValue } from '../module/jsx-ast-utils.js'; function getImplicitRoleForInput(attributes) { const type = getProp(attributes, "type"); if (type) { const value = 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"; } export { getImplicitRoleForInput as default };