Sha256: d7e20d7f4215f1ed5eb61c0ff57dd4b9a264f6bf50ed1065c303585ed70f9c81

Contents?: true

Size: 942 Bytes

Versions: 104

Compression:

Stored size: 942 Bytes

Contents

/* global axe, color */

/**
 * Returns the flattened foreground color of an element, or null if it can't be determined because
 * of transparency
 * @method getForegroundColor
 * @memberof axe.commons.color
 * @instance
 * @param {Element} node
 * @param {Boolean} noScroll (default false)
 * @return {Color|null}
 */
color.getForegroundColor = function(node, noScroll) {
	var nodeStyle = window.getComputedStyle(node);

	var fgColor = new color.Color();
	fgColor.parseRgbString(nodeStyle.getPropertyValue('color'));
	var opacity = nodeStyle.getPropertyValue('opacity');
	fgColor.alpha = fgColor.alpha * opacity;
	if (fgColor.alpha === 1) {
		return fgColor;
	}

	var bgColor = color.getBackgroundColor(node, [], noScroll);
	if (bgColor === null) {
		var reason = axe.commons.color.incompleteData.get('bgColor');
		axe.commons.color.incompleteData.set('fgColor', reason);
		return null;
	}

	return color.flattenColors(fgColor, bgColor);
};

Version data entries

104 entries across 104 versions & 1 rubygems

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