function includeMissingElements(elmStack, elm) {
	/*eslint max-depth:["error",7]*/
	const elementMap = {
		TD: ['TR', 'TBODY'],
		TH: ['TR', 'THEAD'],
		INPUT: ['LABEL']
	};
	const tagArray = elmStack.map(elm => {
		return elm.nodeName;
	});
	let bgNodes = elmStack;
	for (let candidate in elementMap) {
		// check that TR or LABEL has paired nodeName from elementMap, but don't expect elm to be that candidate
		if (tagArray.includes(candidate)) {
			for (let candidateIndex in elementMap[candidate]) {
				if (candidate.hasOwnProperty(candidateIndex)) {
					// look up the tree for a matching candidate
					let ancestorMatch = axe.commons.dom.findUp(
						elm,
						elementMap[candidate][candidateIndex]
					);
					if (ancestorMatch && elmStack.indexOf(ancestorMatch) === -1) {
						// found an ancestor not in elmStack, and it overlaps
						let overlaps = axe.commons.dom.visuallyOverlaps(
							elm.getBoundingClientRect(),
							ancestorMatch
						);
						if (overlaps) {
							// if target is in the elementMap, use its position.
							bgNodes.splice(tagArray.indexOf(candidate) + 1, 0, ancestorMatch);
						}
					}
					// nodeName matches value
					// (such as LABEL, when matching itself. It should be in the list, but Phantom skips it)
					if (
						elm.nodeName === elementMap[candidate][candidateIndex] &&
						tagArray.indexOf(elm.nodeName) === -1
					) {
						bgNodes.splice(tagArray.indexOf(candidate) + 1, 0, elm);
					}
				}
			}
		}
	}
	return bgNodes;
}
function includeMissingElements(elmStack, elm) {
	/*eslint max-depth:["error",7]*/
	const elementMap = {
		TD: ['TR', 'TBODY'],
		TH: ['TR', 'THEAD'],
		INPUT: ['LABEL']
	};
	const tagArray = elmStack.map(elm => {
		return elm.nodeName;
	});
	let bgNodes = elmStack;
	for (let candidate in elementMap) {
		// check that TR or LABEL has paired nodeName from elementMap, but don't expect elm to be that candidate
		if (tagArray.includes(candidate)) {
			for (let candidateIndex in elementMap[candidate]) {
				if (candidate.hasOwnProperty(candidateIndex)) {
					// look up the tree for a matching candidate
					let ancestorMatch = axe.commons.dom.findUp(
						elm,
						elementMap[candidate][candidateIndex]
					);
					if (ancestorMatch && elmStack.indexOf(ancestorMatch) === -1) {
						// found an ancestor not in elmStack, and it overlaps
						let overlaps = axe.commons.dom.visuallyOverlaps(
							elm.getBoundingClientRect(),
							ancestorMatch
						);
						if (overlaps) {
							// if target is in the elementMap, use its position.
							bgNodes.splice(tagArray.indexOf(candidate) + 1, 0, ancestorMatch);
						}
					}
					// nodeName matches value
					// (such as LABEL, when matching itself. It should be in the list, but Phantom skips it)
					if (
						elm.nodeName === elementMap[candidate][candidateIndex] &&
						tagArray.indexOf(elm.nodeName) === -1
					) {
						bgNodes.splice(tagArray.indexOf(candidate) + 1, 0, elm);
					}
				}
			}
		}
	}
	return bgNodes;
}
function includeMissingElements ( elmStack , elm ) { /*eslint max-depth:["error",7]*/ const elementMap = { TD : [ 'TR' , 'TBODY' ] , TH : [ 'TR' , 'THEAD' ] , INPUT : [ 'LABEL' ] } ; const tagArray = elmStack . map ( elm => { return elm . nodeName ; } ) ; let bgNodes = elmStack ; for ( let candidate in elementMap ) { // check that TR or LABEL has paired nodeName from elementMap, but don't expect elm to be that candidate if ( tagArray . includes ( candidate ) ) { for ( let candidateIndex in elementMap [ candidate ] ) { if ( candidate . hasOwnProperty ( candidateIndex ) ) { // look up the tree for a matching candidate let ancestorMatch = axe . commons . dom . findUp ( elm , elementMap [ candidate ] [ candidateIndex ] ) ; if ( ancestorMatch && elmStack . indexOf ( ancestorMatch ) === - 1 ) { // found an ancestor not in elmStack, and it overlaps let overlaps = axe . commons . dom . visuallyOverlaps ( elm . getBoundingClientRect ( ) , ancestorMatch ) ; if ( overlaps ) { // if target is in the elementMap, use its position. bgNodes . splice ( tagArray . indexOf ( candidate ) + 1 , 0 , ancestorMatch ) ; } } // nodeName matches value // (such as LABEL, when matching itself. It should be in the list, but Phantom skips it) if ( elm . nodeName === elementMap [ candidate ] [ candidateIndex ] && tagArray . indexOf ( elm . nodeName ) === - 1 ) { bgNodes . splice ( tagArray . indexOf ( candidate ) + 1 , 0 , elm ) ; } } } } } return bgNodes ; }
Include nodes missing from initial gathering because
document.elementsFromPoint misses some elements we need
i.e. TR is missing from table elementStack and leaves out bgColor
https://github.com/dequelabs/axe-core/issues/273
@private
@param {Array} elmStack
@param {Element} elm
@returns {Array}
Include nodes missing from initial gathering because document . elementsFromPoint misses some elements we need i . e . TR is missing from table elementStack and leaves out bgColor https : // github . com / dequelabs / axe - core / issues / 273
This function is used to include elements that are not in the elementStack.