Sha256: 2d165586cc260ac68d87292eeccc3b7ecfba9866bb3b63c3b0385c13642f8cbd

Contents?: true

Size: 628 Bytes

Versions: 271

Compression:

Stored size: 628 Bytes

Contents

/* global axe */

const possibleShadowRoots = [
	'article',
	'aside',
	'blockquote',
	'body',
	'div',
	'footer',
	'h1',
	'h2',
	'h3',
	'h4',
	'h5',
	'h6',
	'header',
	'main',
	'nav',
	'p',
	'section',
	'span'
];
/**
 * Test a node to see if it has a spec-conforming shadow root
 *
 * @param {Node}   node  The HTML DOM node
 * @return {Boolean}
 */
axe.utils.isShadowRoot = function isShadowRoot(node) {
	if (node.shadowRoot) {
		const nodeName = node.nodeName.toLowerCase();
		if (
			possibleShadowRoots.includes(nodeName) ||
			/^[a-z][a-z0-9_.-]*-[a-z0-9_.-]*$/.test(nodeName)
		) {
			return true;
		}
	}
	return false;
};

Version data entries

271 entries across 271 versions & 1 rubygems

Version Path
govuk_publishing_components-27.9.1 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.9.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.8.2 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.8.1 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.8.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.7.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.6.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.5.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.4.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.3.1 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.3.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.2.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.1.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-27.0.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-26.0.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-25.7.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-25.6.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-25.5.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-25.4.0 node_modules/axe-core/lib/core/utils/is-shadow-root.js
govuk_publishing_components-25.3.1 node_modules/axe-core/lib/core/utils/is-shadow-root.js