Sha256: f641a19297ca77dee6887aa98d0bcad73579ec832e0c34dc11e3eb68e690cea9

Contents?: true

Size: 1.57 KB

Versions: 375

Compression:

Stored size: 1.57 KB

Contents

/**
 * A map from HTML tag names to a boolean which reflects whether it is
 * appropriate for scrollable elements found in the focus order.
 */
const VALID_TAG_NAMES_FOR_SCROLLABLE_REGIONS = {
	ARTICLE: true,
	ASIDE: true,
	NAV: true,
	SECTION: true
};

/**
 * A map from each landmark role to a boolean which reflects whether it is
 * appropriate for scrollable elements found in the focus order.
 */
const VALID_ROLES_FOR_SCROLLABLE_REGIONS = {
	application: true,
	banner: false,
	complementary: true,
	contentinfo: true,
	form: true,
	main: true,
	navigation: true,
	region: true,
	search: false
};

/**
 * @param {HTMLElement} node
 * @return {Boolean} Whether the element has a tag appropriate for a scrollable
 *		 region.
 */
function validScrollableTagName(node) {
	// Some elements with nonsensical roles will pass this check, but should be
	// flagged by other checks.
	const nodeName = node.nodeName.toUpperCase();
	return VALID_TAG_NAMES_FOR_SCROLLABLE_REGIONS[nodeName] || false;
}

/**
 * @param {HTMLElement} node
 * @return {Boolean} Whether the node has a role appropriate for a scrollable
 *		 region.
 */
function validScrollableRole(node) {
	var role = node.getAttribute('role');
	if (!role) {
		return false;
	}
	return VALID_ROLES_FOR_SCROLLABLE_REGIONS[role.toLowerCase()] || false;
}

/**
 * @param {HTMLElement} node
 * @return {Boolean} Whether the element would have valid semantics if it were a
 *			scrollable region.
 */
function validScrollableSemantics(node) {
	return validScrollableRole(node) || validScrollableTagName(node);
}

return validScrollableSemantics(node);

Version data entries

375 entries across 375 versions & 1 rubygems

Version Path
govuk_publishing_components-30.4.1 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-30.4.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-30.3.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-30.2.1 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-30.2.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-30.1.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-30.0.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.15.3 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.15.2 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.15.1 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.15.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.14.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.13.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.12.1 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.12.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.11.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.10.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.9.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.8.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js
govuk_publishing_components-29.7.0 node_modules/axe-core/lib/checks/aria/valid-scrollable-semantics.js