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.22.1 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.22.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.21.3 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.21.2 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.21.1 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.21.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.20.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.19.1 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.19.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.18.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.17.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.16.3 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.16.2 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.16.1 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.16.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.15.2 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.15.1 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.15.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.14.0 node_modules/axe-core/lib/commons/matches/node-name.js
govuk_publishing_components-21.13.5 node_modules/axe-core/lib/commons/matches/node-name.js