Sha256: 3b3729fa6c7e2bcc91c6d36444f39d61292cba6280cc794fbc1de9ef875bf8a2
Contents?: true
Size: 2 KB
Versions: 104
Compression:
Stored size: 2 KB
Contents
// Select and textarea is always allowed if (node.nodeName.toUpperCase() !== 'INPUT') { return true; } const number = ['text', 'search', 'number']; const url = ['text', 'search', 'url']; const allowedTypesMap = { bday: ['text', 'search', 'date'], email: ['text', 'search', 'email'], 'cc-exp': ['text', 'search', 'month'], 'street-address': ['text'], // Issue: https://github.com/dequelabs/axe-core/issues/1161 tel: ['text', 'search', 'tel'], 'cc-exp-month': number, 'cc-exp-year': number, 'transaction-amount': number, 'bday-day': number, 'bday-month': number, 'bday-year': number, 'new-password': ['text', 'search', 'password'], 'current-password': ['text', 'search', 'password'], url: url, photo: url, impp: url }; if (typeof options === 'object') { // Merge in options Object.keys(options).forEach(key => { if (!allowedTypesMap[key]) { allowedTypesMap[key] = []; } allowedTypesMap[key] = allowedTypesMap[key].concat(options[key]); }); } const autocomplete = node.getAttribute('autocomplete'); const autocompleteTerms = autocomplete .split(/\s+/g) .map(term => term.toLowerCase()); const purposeTerm = autocompleteTerms[autocompleteTerms.length - 1]; if (axe.commons.text.autocomplete.stateTerms.includes(purposeTerm)) { return true; } const allowedTypes = allowedTypesMap[purposeTerm]; /** * Note: * Inconsistent response for `node.type` across browsers, hence resolving and sanitizing using getAttribute * Example: * Firefox returns `node.type` as `text` for `type='month'` * * Reference HTML Spec - https://html.spec.whatwg.org/multipage/input.html#the-input-element to filter allowed values for `type` * and sanitize (https://html.spec.whatwg.org/multipage/input.html#value-sanitization-algorithm) */ let type = node.hasAttribute('type') ? axe.commons.text.sanitize(node.getAttribute('type')).toLowerCase() : 'text'; type = axe.utils.validInputTypes().includes(type) ? type : 'text'; if (typeof allowedTypes === 'undefined') { return type === 'text'; } return allowedTypes.includes(type);
Version data entries
104 entries across 104 versions & 1 rubygems