UNPKG

d2-ui

Version:
48 lines (39 loc) 1.22 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getImplicitRoleForInput; var _getAttribute = require('../getAttribute'); var _getAttribute2 = _interopRequireDefault(_getAttribute); var _getAttributeValue = require('../getAttributeValue'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Returns the implicit role for an input tag. */ function getImplicitRoleForInput(attributes) { var type = (0, _getAttribute2.default)(attributes, 'type'); if (type) { var value = (0, _getAttributeValue.getLiteralAttributeValue)(type) || ''; switch (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': // with [list] selector it's combobox case 'TEL': // with [list] selector it's combobox case 'URL': // with [list] selector it's combobox default: return 'textbox'; } } return 'textbox'; }