Sha256: e49ea504ae3985345196e2b52066ed190da5702bb4792b82e952c15a3fe2de48

Contents?: true

Size: 1.33 KB

Versions: 104

Compression:

Stored size: 1.33 KB

Contents

const { text, aria, dom } = axe.commons;

const autocomplete = node.getAttribute('autocomplete');
if (!autocomplete || text.sanitize(autocomplete) === '') {
	return false;
}

const nodeName = node.nodeName.toUpperCase();
if (['TEXTAREA', 'INPUT', 'SELECT'].includes(nodeName) === false) {
	return false;
}

// The element is an `input` element a `type` of `hidden`, `button`, `submit` or `reset`
const excludedInputTypes = ['submit', 'reset', 'button', 'hidden'];
if (nodeName === 'INPUT' && excludedInputTypes.includes(node.type)) {
	return false;
}

// The element has a `disabled` or `aria-disabled="true"` attribute
const ariaDisabled = node.getAttribute('aria-disabled') || 'false';
if (node.disabled || ariaDisabled.toLowerCase() === 'true') {
	return false;
}

// The element has `tabindex="-1"` and has a [[semantic role]] that is
//   not a [widget](https://www.w3.org/TR/wai-aria-1.1/#widget_roles)
const role = node.getAttribute('role');
const tabIndex = node.getAttribute('tabindex');
if (tabIndex === '-1' && role) {
	const roleDef = aria.lookupTable.role[role];
	if (roleDef === undefined || roleDef.type !== 'widget') {
		return false;
	}
}

// The element is **not** visible on the page or exposed to assistive technologies
if (
	tabIndex === '-1' &&
	!dom.isVisible(node, false) &&
	!dom.isVisible(node, true)
) {
	return false;
}

return true;

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
govuk_publishing_components-16.25.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.24.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.23.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.22.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.21.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.20.1 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.20.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.19.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.18.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.17.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.16.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.15.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.14.1 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.14.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.13.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.12.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.11.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.10.1 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.10.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-16.9.2 node_modules/axe-core/lib/rules/autocomplete-matches.js