Sha256: ab82f4a1b8d9b6fc1a37025cc0241ef4a85ece3da847de98cf36a5b3c1418274

Contents?: true

Size: 969 Bytes

Versions: 115

Compression:

Stored size: 969 Bytes

Contents

/* global matches */
let isXHTMLGlobal;
/**
 * Check if the nodeName of a node matches some value
 *
 * Note: matches.nodeName(node, matcher) can be indirectly used through
 * matches(node, { nodeName: matcher })
 *
 * Example:
 * ```js
 * matches.nodeName(node, ['div', 'span'])
 * ```
 *
 * @param {HTMLElement|VirtualNode} node
 * @param {Object} Attribute matcher
 * @returns {Boolean}
 */
matches.nodeName = function matchNodeName(node, matcher, { isXHTML } = {}) {
	node = node.actualNode || node;
	if (typeof isXHTML === 'undefined') {
		// When the matcher is a string, use native .matches() function:
		if (typeof matcher === 'string') {
			return axe.utils.matchesSelector(node, matcher);
		}

		if (typeof isXHTMLGlobal === 'undefined') {
			isXHTMLGlobal = axe.utils.isXHTML(node.ownerDocument);
		}
		isXHTML = isXHTMLGlobal;
	}

	const nodeName = isXHTML ? node.nodeName : node.nodeName.toLowerCase();
	return matches.fromPrimative(nodeName, matcher);
};

Version data entries

115 entries across 115 versions & 1 rubygems

Version Path
govuk_publishing_components-21.13.4 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.13.3 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.13.2 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.13.1 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.13.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.12.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.11.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.10.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.9.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.8.1 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.8.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.7.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.6.1 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.6.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.5.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.4.1 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.4.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.3.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.2.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.1.1 node_modules/axe-core/lib/commons/matches/node-name.js