Sha256: 7a6a9db9935b414ab2f4de1193f5598c9d86b4d3499e278bb96e1e3e5435722d

Contents?: true

Size: 1.82 KB

Versions: 375

Compression:

Stored size: 1.82 KB

Contents

(function() {
	/**
	 * Calculates the result of a Rule based on its types and the result of its child Checks
	 * @param	{Array} nodeResults The array of nodes tested by the Rule
	 */
	axe.utils.aggregateNodeResults = function(nodeResults) {
		let ruleResult = {};

		// For each node, retrieve the result and impact
		nodeResults = nodeResults.map(function(nodeResult) {
			// Known result
			if (nodeResult.any && nodeResult.all && nodeResult.none) {
				return axe.utils.aggregateChecks(nodeResult);
			} else if (Array.isArray(nodeResult.node)) {
				return axe.utils.finalizeRuleResult(nodeResult);
			} else {
				throw new TypeError('Invalid Result type');
			}
		});

		// Aggregate the result
		// If there were no nodes passed in, mark the test as inapplicable
		if (nodeResults && nodeResults.length) {
			let resultList = nodeResults.map(node => node.result);
			ruleResult.result = axe.utils.aggregate(
				axe.constants.results,
				resultList,
				ruleResult.result
			);
		} else {
			ruleResult.result = 'inapplicable';
		}

		// Create an array for each type
		axe.constants.resultGroups.forEach(group => (ruleResult[group] = []));

		// Fill the array with nodes
		nodeResults.forEach(function(nodeResult) {
			var groupName = axe.constants.resultGroupMap[nodeResult.result];
			ruleResult[groupName].push(nodeResult);
		});

		// Take the highest impact of failed or canttell rules
		var impactGroup = axe.constants.FAIL_GROUP;
		if (ruleResult[impactGroup].length === 0) {
			impactGroup = axe.constants.CANTTELL_GROUP;
		}

		if (ruleResult[impactGroup].length > 0) {
			// Get the impact of all issues
			let impactList = ruleResult[impactGroup].map(failure => failure.impact);

			ruleResult.impact =
				axe.utils.aggregate(axe.constants.impact, impactList) || null;
		} else {
			ruleResult.impact = null;
		}

		return ruleResult;
	};
})();

Version data entries

375 entries across 375 versions & 1 rubygems

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