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-21.16.3 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.16.2 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.16.1 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.16.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.15.2 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.15.1 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.15.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.14.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.13.5 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.13.4 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.13.3 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.13.2 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.13.1 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.13.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.12.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.11.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.10.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.9.0 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.8.1 node_modules/axe-core/lib/rules/autocomplete-matches.js
govuk_publishing_components-21.8.0 node_modules/axe-core/lib/rules/autocomplete-matches.js