_checkValidNamespace = function _checkValidNamespace(element) {
		let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode
		// can be null. We just simulate parent in this case.

		if (!parent || !parent.tagName) {
			parent = {
				namespaceURI: NAMESPACE,
				tagName: 'template'
			};
		}

		const tagName = stringToLowerCase(element.tagName);
		const parentTagName = stringToLowerCase(parent.tagName);

		if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
			return false;
		}

		if (element.namespaceURI === SVG_NAMESPACE) {
			// The only way to switch from HTML namespace to SVG
			// is via <svg>. If it happens via any other tag, then
			// it should be killed.
			if (parent.namespaceURI === HTML_NAMESPACE) {
				return tagName === 'svg';
			} // The only way to switch from MathML to SVG is via`
			// svg if parent is either <annotation-xml> or MathML
			// text integration points.


			if (parent.namespaceURI === MATHML_NAMESPACE) {
				return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
			} // We only allow elements that are defined in SVG
			// spec. All others are disallowed in SVG namespace.


			return Boolean(ALL_SVG_TAGS[tagName]);
		}

		if (element.namespaceURI === MATHML_NAMESPACE) {
			// The only way to switch from HTML namespace to MathML
			// is via <math>. If it happens via any other tag, then
			// it should be killed.
			if (parent.namespaceURI === HTML_NAMESPACE) {
				return tagName === 'math';
			} // The only way to switch from SVG to MathML is via
			// <math> and HTML integration points


			if (parent.namespaceURI === SVG_NAMESPACE) {
				return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
			} // We only allow elements that are defined in MathML
			// spec. All others are disallowed in MathML namespace.


			return Boolean(ALL_MATHML_TAGS[tagName]);
		}

		if (element.namespaceURI === HTML_NAMESPACE) {
			// The only way to switch from SVG to HTML is via
			// HTML integration points, and from MathML to HTML
			// is via MathML text integration points
			if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
				return false;
			}

			if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
				return false;
			} // We disallow tags that are specific for MathML
			// or SVG and should never appear in HTML namespace


			return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
		} // For XHTML and XML documents that support custom namespaces


		if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
			return true;
		} // The code should never reach this place (this means
		// that the element somehow got namespace that is not
		// HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
		// Return false just in case.


		return false;
	}
@param  {Element} element a DOM element whose namespace is being checked
@returns {boolean} Return false if the element has a
 namespace that a spec-compliant parser would never
 return. Return true otherwise.