<commit_before>import isVoid from '../util/isVoid';
import isStringOrNumber from '../util/isStringOrNumber';
import isSVGElement from '../util/isSVGElement';
import isMathMLElement from '../util/isMathMLElement';
import createRootNodeWithDynamicText from './shapes/rootNodeWithDynamicText';
import createNodeWithDynamicText from './shapes/nodeWithDynamicText';
import createRootNodeWithStaticChild from './shapes/rootNodeWithStaticChild';
import createNodeWithStaticChild from './shapes/nodeWithStaticChild';
import createRootNodeWithDynamicChild from './shapes/rootNodeWithDynamicChild';
import createNodeWithDynamicChild from './shapes/nodeWithDynamicChild';
import createRootNodeWithDynamicSubTreeForChildren from './shapes/rootNodeWithDynamicSubTreeForChildren';
import createNodeWithDynamicSubTreeForChildren from './shapes/nodeWithDynamicSubTreeForChildren';
//import createRootDynamicNode from './shapes/rootDynamicNode';
import createDynamicNode from './shapes/dynamicNode';
import createRootNodeWithComponent from './shapes/rootNodeWithComponent';
import createNodeWithComponent from './shapes/nodeWithComponent';
import createRootDynamicTextNode from './shapes/rootDynamicTextNode';
//import createDynamicTextNode from './shapes/dynamicTextNode';
import { ObjectTypes } 	from '../core/variables';
import isArray from '../util/isArray';
import { addDOMStaticAttributes } from './addAttributes';
import { isRecyclingEnabled } from './recycling';

import createRootVoidNode from './shapes/rootVoidNode';
import createVoidNode from './shapes/voidNode';
import createRootStaticNode from './shapes/rootStaticNode';
import createStaticNode from './shapes/staticNode';


function createElement(schema, domNamespace, parentNode, dominic) {

	const MathNamespace = 'http://www.w3.org/1998/Math/MathML';
	const SVGNamespace = 'http://www.w3.org/2000/svg';
	const nodeName = schema.tag.toLowerCase();
	const is = schema.attrs && schema.attrs.is;

	let templateNode;

	if ( domNamespace === undefined ) {
		if ( schema.attrs && schema.attrs.xmlns ) {
			domNamespace = schema.attrs.xmlns;
		} else {
			switch ( nodeName ) {
				case 'svg':
					domNamespace = 'http://www.w3.org/2000/svg';
					break;
				case 'math':
					domNamespace = 'http://www.w3.org/1998/Math/MathML';
					break;
				default:
					if ( dominic === 'static') {
						// Edge case. In case a namespace element are wrapped inside a non-namespace element, it will inherit wrong namespace.
						// E.g. <div><svg><svg></div> - will not work
						if ( parentNode !== null ) { // only used by static children
							// check only for top-level element for both mathML and SVG
							if ( nodeName === 'svg' && parentNode.namespaceURI !== SVGNamespace ) {
								domNamespace = SVGNamespace;
							} else if ( nodeName === 'math' && parentNode.namespaceURI !== MathNamespace ) {
								domNamespace = MathNamespace;
							}
						} else if ( isSVGElement( nodeName ) ) { // only used by dynamic children
							domNamespace = SVGNamespace;
						} else if ( isMathMLElement( nodeName ) ) { // only used by dynamic children
							domNamespace = MathNamespace;
						}
					}
			}
		}
	}

	if ( domNamespace ) {
		if ( is ) {
			templateNode = document.createElementNS( domNamespace, nodeName, is );
		} else {
			templateNode = document.createElementNS( domNamespace, nodeName );
		}
	} else {
		if ( is ) {
			templateNode = document.createElement( nodeName, is );
		} else {
			templateNode = document.createElement( nodeName );
		}
	}

	return {
		namespace: domNamespace,
		node: templateNode
	};
}

const recyclingEnabled = isRecyclingEnabled();
const invalidTemplateError = 'Inferno Error: A valid template node must be returned. You may have returned undefined, an array or some other invalid object.';

function createStaticAttributes( node, domNode, excludeAttrs ) {
	const attrs = node.attrs;

	if ( !isVoid( attrs ) ) {
		if ( excludeAttrs ) {
			const newAttrs = { ...attrs };

			for ( const attr in excludeAttrs ) {
				if ( newAttrs[attr] ) {
					delete newAttrs[attr];
				}
			}
			addDOMStaticAttributes( node, domNode, newAttrs );
		} else {
			addDOMStaticAttributes( node, domNode, attrs );
		}
	}
}

function createStaticTreeChildren( children, parentNode, domNamespace ) {
	if ( isArray( children ) ) {
		for ( let i = 0; i < children.length; i++ ) {
			const childItem = children[i];

			if ( isStringOrNumber( childItem ) ) {
				const textNode = document.createTextNode( childItem );

				parentNode.appendChild( textNode );
			} else {
				createStaticTreeNode( childItem, parentNode, domNamespace );
			}
		}
	} else {
		if ( isStringOrNumber( children ) ) {
			parentNode.textContent = children;
		} else {
			createStaticTreeNode( children, parentNode, domNamespace );
		}
	}
}

function createStaticTreeNode( node, parentNode, domNamespace ) {
	let staticNode;

	if ( isVoid( node ) ) {
		return null;
	}
	if ( isStringOrNumber( node ) ) {
		staticNode = document.createTextNode( node );
	} else {
		const tag = node.tag;

		if ( tag ) {

			const nodeName = tag.toLowerCase();
			const is = node.attrs && node.attrs.is;
			const MathNamespace = 'http://www.w3.org/1998/Math/MathML';
			const SVGNamespace = 'http://www.w3.org/2000/svg';

			const Element = createElement(node, domNamespace, parentNode, 'static')
			staticNode = Element.node;
			domNamespace = Element.namespace;


			const text = node.text;
			const children = node.children;

			if ( !isVoid( text ) ) {

				if ( process.env.NODE_ENV !== 'production' ) {

					if ( !isVoid( children ) ) {
						throw Error( invalidTemplateError );
					}<commit_msg>removed more dead code<commit_after>import isVoid from '../util/isVoid';
import isStringOrNumber from '../util/isStringOrNumber';
import isSVGElement from '../util/isSVGElement';
import isMathMLElement from '../util/isMathMLElement';
import createRootNodeWithDynamicText from './shapes/rootNodeWithDynamicText';
import createNodeWithDynamicText from './shapes/nodeWithDynamicText';
import createRootNodeWithStaticChild from './shapes/rootNodeWithStaticChild';
import createNodeWithStaticChild from './shapes/nodeWithStaticChild';
import createRootNodeWithDynamicChild from './shapes/rootNodeWithDynamicChild';
import createNodeWithDynamicChild from './shapes/nodeWithDynamicChild';
import createRootNodeWithDynamicSubTreeForChildren from './shapes/rootNodeWithDynamicSubTreeForChildren';
import createNodeWithDynamicSubTreeForChildren from './shapes/nodeWithDynamicSubTreeForChildren';
//import createRootDynamicNode from './shapes/rootDynamicNode';
import createDynamicNode from './shapes/dynamicNode';
import createRootNodeWithComponent from './shapes/rootNodeWithComponent';
import createNodeWithComponent from './shapes/nodeWithComponent';
import createRootDynamicTextNode from './shapes/rootDynamicTextNode';
//import createDynamicTextNode from './shapes/dynamicTextNode';
import { ObjectTypes } 	from '../core/variables';
import isArray from '../util/isArray';
import { addDOMStaticAttributes } from './addAttributes';
import { isRecyclingEnabled } from './recycling';

import createRootVoidNode from './shapes/rootVoidNode';
import createVoidNode from './shapes/voidNode';
import createRootStaticNode from './shapes/rootStaticNode';
import createStaticNode from './shapes/staticNode';


function createElement(schema, domNamespace, parentNode, dominic) {

	const MathNamespace = 'http://www.w3.org/1998/Math/MathML';
	const SVGNamespace = 'http://www.w3.org/2000/svg';
	const nodeName = schema.tag.toLowerCase();
	const is = schema.attrs && schema.attrs.is;

	let templateNode;

	if ( domNamespace === undefined ) {
		if ( schema.attrs && schema.attrs.xmlns ) {
			domNamespace = schema.attrs.xmlns;
		} else {
			switch ( nodeName ) {
				case 'svg':
					domNamespace = 'http://www.w3.org/2000/svg';
					break;
				case 'math':
					domNamespace = 'http://www.w3.org/1998/Math/MathML';
					break;
				default:
					if ( dominic === 'static') {
						// Edge case. In case a namespace element are wrapped inside a non-namespace element, it will inherit wrong namespace.
						// E.g. <div><svg><svg></div> - will not work
						if ( parentNode !== null ) { // only used by static children
							// check only for top-level element for both mathML and SVG
							if ( nodeName === 'svg' && parentNode.namespaceURI !== SVGNamespace ) {
								domNamespace = SVGNamespace;
							} else if ( nodeName === 'math' && parentNode.namespaceURI !== MathNamespace ) {
								domNamespace = MathNamespace;
							}
						} else if ( isSVGElement( nodeName ) ) { // only used by dynamic children
							domNamespace = SVGNamespace;
						} else if ( isMathMLElement( nodeName ) ) { // only used by dynamic children
							domNamespace = MathNamespace;
						}
					}
			}
		}
	}

	if ( domNamespace ) {
		if ( is ) {
			templateNode = document.createElementNS( domNamespace, nodeName, is );
		} else {
			templateNode = document.createElementNS( domNamespace, nodeName );
		}
	} else {
		if ( is ) {
			templateNode = document.createElement( nodeName, is );
		} else {
			templateNode = document.createElement( nodeName );
		}
	}

	return {
		namespace: domNamespace,
		node: templateNode
	};
}

const recyclingEnabled = isRecyclingEnabled();
const invalidTemplateError = 'Inferno Error: A valid template node must be returned. You may have returned undefined, an array or some other invalid object.';

function createStaticAttributes( node, domNode, excludeAttrs ) {
	const attrs = node.attrs;

	if ( !isVoid( attrs ) ) {
		if ( excludeAttrs ) {
			const newAttrs = { ...attrs };

			for ( const attr in excludeAttrs ) {
				if ( newAttrs[attr] ) {
					delete newAttrs[attr];
				}
			}
			addDOMStaticAttributes( node, domNode, newAttrs );
		} else {
			addDOMStaticAttributes( node, domNode, attrs );
		}
	}
}

function createStaticTreeChildren( children, parentNode, domNamespace ) {
	if ( isArray( children ) ) {
		for ( let i = 0; i < children.length; i++ ) {
			const childItem = children[i];

			if ( isStringOrNumber( childItem ) ) {
				const textNode = document.createTextNode( childItem );

				parentNode.appendChild( textNode );
			} else {
				createStaticTreeNode( childItem, parentNode, domNamespace );
			}
		}
	} else {
		if ( isStringOrNumber( children ) ) {
			parentNode.textContent = children;
		} else {
			createStaticTreeNode( children, parentNode, domNamespace );
		}
	}
}

function createStaticTreeNode( node, parentNode, domNamespace ) {
	let staticNode;

	if ( isVoid( node ) ) {
		return null;
	}
	if ( isStringOrNumber( node ) ) {
		staticNode = document.createTextNode( node );
	} else {
		const tag = node.tag;

		if ( tag ) {

			const Element = createElement(node, domNamespace, parentNode, 'static')
			staticNode = Element.node;
			domNamespace = Element.namespace;


			const text = node.text;
			const children = node.children;

			if ( !isVoid( text ) ) {

				if ( process.env.NODE_ENV !== 'production' ) {

					if ( !isVoid( children ) ) {
						throw Error( invalidTemplateError );
					}
{'fraction_non_alphanumeric': 0.11635475996745322, 'fraction_numerical': 0.004701202422927403, 'mean_word_length': 3.7722174288179464, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1963479', 'n_tokens_mistral': 3696, 'n_tokens_neox': 3222, 'n_words': 840}