Sha256: 4ae9082ddc893738f333db6d10f8d645e884bebe3f4d353ed76c57521b9430bd

Contents?: true

Size: 705 Bytes

Versions: 104

Compression:

Stored size: 705 Bytes

Contents

const id = axe.utils.escapeSelector(node.getAttribute('id'));
let labels = Array.from(document.querySelectorAll(`label[for="${id}"]`));
let parent = node.parentNode;

if (labels.length) {
	// filter out hidden labels because they're fine
	// except: fail first label if hidden because of VO
	labels = labels.filter(function(label, index) {
		if (
			(index === 0 && !axe.commons.dom.isVisible(label, true)) ||
			axe.commons.dom.isVisible(label, true)
		) {
			return label;
		}
	});
}

while (parent) {
	if (
		parent.nodeName.toUpperCase() === 'LABEL' &&
		labels.indexOf(parent) === -1
	) {
		labels.push(parent);
	}
	parent = parent.parentNode;
}

this.relatedNodes(labels);
return labels.length > 1;

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
govuk_publishing_components-21.16.3 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.16.2 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.16.1 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.16.0 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.15.2 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.15.1 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.15.0 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.14.0 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.13.5 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.13.4 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.13.3 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.13.2 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.13.1 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.13.0 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.12.0 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.11.0 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.10.0 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.9.0 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.8.1 node_modules/axe-core/lib/checks/label/multiple-label.js
govuk_publishing_components-21.8.0 node_modules/axe-core/lib/checks/label/multiple-label.js