Sha256: 6cd6fbebc453ed3ee86a707b5c75c18cd7bd6dea8e4a4885a2df077957e6077a

Contents?: true

Size: 964 Bytes

Versions: 104

Compression:

Stored size: 964 Bytes

Contents

/**
 * Wrapper for Node#contains; PhantomJS does not support Node#contains and erroneously reports that it does
 * @method contains
 * @memberof axe.utils
 * @param  {HTMLElement} node      The candidate container node
 * @param  {HTMLElement} otherNode The node to test is contained by `node`
 * @return {Boolean}           Whether `node` contains `otherNode`
 */
axe.utils.contains = function(node, otherNode) {
	/*eslint no-bitwise: 0*/
	'use strict';
	function containsShadowChild(node, otherNode) {
		if (node.shadowId === otherNode.shadowId) {
			return true;
		}
		return !!node.children.find(child => {
			return containsShadowChild(child, otherNode);
		});
	}

	if (node.shadowId || otherNode.shadowId) {
		return containsShadowChild(node, otherNode);
	}

	if (typeof node.actualNode.contains === 'function') {
		return node.actualNode.contains(otherNode.actualNode);
	}

	return !!(node.actualNode.compareDocumentPosition(otherNode.actualNode) & 16);
};

Version data entries

104 entries across 104 versions & 1 rubygems

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