<commit_before>import attrNameCfg from './cfg/attrNameCfg';
import propNameCfg from './cfg/propNameCfg';
import hasPropertyAccessor from './hasPropertyAccessor';
import dasherize from './dasherize';
import camelize from './camelize';
import inArray from '../util/inArray';
import isArray from '../util/isArray';
import isSVG from '../util/isSVG';
import escapeHtml from './escapeHtml';
import unitlessCfg from './cfg/unitlessCfg';

// Simplified subset
let VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][a-zA-Z_\.\-\d]*$/,
    illegalAttributeNameCache = {},
    validatedAttributeNameCache = {},

 xmlMap = {
	'xml:base': 'base',
	'xml:id': 'id',
	'xml:lang': 'lang',
	'xml:space': 'spac'
},

 xlinkMap = {
	'xlink:actuate': 'actuate',
	'xlink:arcrole': 'arcrole',
	'xlink:href': 'href',
	'xlink:role': 'role',
	'xlink:show': 'show',
	'xlink:title': 'title',
	'xlink:type': 'type'
};

/**
 * Returns a DOM node tagName as lowerCase
 * @param {Object} node A DOM element.
 */
let getNodeName = (node) => {
	
	// TODO!! Cache this for re-use?
    return node.tagName.toLowerCase();	
};

/**
 * Normalize CSS properties for SSR
 *
 * @param {String} name The boolean attribute name to set.
 * @param {String} value The boolean attribute value to set.
 */
let normalize = (name, value) => {
	if (value === null || (value === '')) {
		return '';
	}
	if (value === 0 || (unitlessCfg[name] || (isNaN(value)))) {
		return '' + value; // cast to string
	}
	if (typeof value === 'string') {
		value = value.trim();
	}
	return value + 'px';
};

/**
 * Validate custom attributes
 *
 * @param  {String} name  The boolean attribute name to set.
 */
 let validateAttribute = ( name ) => {

    if ( validatedAttributeNameCache[name] ) {
        return true;
    }

    if ( illegalAttributeNameCache[name] ) {
        return false;
    }
     // namespace attributes are seen as non-valid, avoid that!
     if ( VALID_ATTRIBUTE_NAME_REGEX.test( name ) || 
	    ( xmlMap[name] ) || 
		( xlinkMap[name] ) ) {
			
        validatedAttributeNameCache[name] = true;
        return true;
    }

    illegalAttributeNameCache[name] = true;

    return false;
};

/**
 * Set boolean attributes
 *
 * @param  {Object} node A DOM element.
 * @param  {String} name  The boolean attribute name to set.
 * @param {String} value The boolean attribute value to set.
 */
let setBooleanAttribute = (node, name, value) => {
	// Avoid touching the DOM and set falsy attributes.
	if (value !== false) {
		node.setAttribute(name, '' + (value === true ? '' : value));
	}
};

/**
 * Set Inferno attributes
 *
 * @param  {Object} node A DOM element.
 * @param  {String} name  The boolean attribute name to set.
 * @param {String} value The boolean attribute value to set.
 */
let setInfernoAttribute = (node, name, value) => {
	node.setAttribute(name, value);
};

/**
 * Set custom attributes on a DOM node
 *
 * @param {Object} node A DOM element.
 * @param {String} name	 The attribute name to set.
 * @param {String} value  The attribute value to set.
 */<commit_msg>quick fix<commit_after>import attrNameCfg from './cfg/attrNameCfg';
import propNameCfg from './cfg/propNameCfg';
import hasPropertyAccessor from './hasPropertyAccessor';
import dasherize from './dasherize';
import camelize from './camelize';
import inArray from '../util/inArray';
import isArray from '../util/isArray';
import isSVG from '../util/isSVG';
import escapeHtml from './escapeHtml';
import unitlessCfg from './cfg/unitlessCfg';

// Simplified subset
let VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][a-zA-Z_\.\-\d]*$/,
    illegalAttributeNameCache = {},
    validatedAttributeNameCache = {},

 xmlMap = {
	'xml:base': 'base',
	'xml:id': 'id',
	'xml:lang': 'lang',
	'xml:space': 'spac'
},

 xlinkMap = {
	'xlink:actuate': 'actuate',
	'xlink:arcrole': 'arcrole',
	'xlink:href': 'href',
	'xlink:role': 'role',
	'xlink:show': 'show',
	'xlink:title': 'title',
	'xlink:type': 'type'
};

/**
 * Returns a DOM node tagName as lowerCase
 * @param {Object} node A DOM element.
 */
let getNodeName = (node) => {
	
	// TODO!! Cache this for re-use?
    return node.tagName.toLowerCase();	
};

/**
 * Normalize CSS properties for SSR
 *
 * @param {String} name The boolean attribute name to set.
 * @param {String} value The boolean attribute value to set.
 */
let normalize = (name, value) => {
	if (value === null || (value === '')) {
		return '';
	}
	if (value === 0 || (unitlessCfg[name] || (isNaN(value)))) {
		return '' + value; // cast to string
	}
	if (typeof value === 'string') {
		value = value.trim();
	}
	return value + 'px';
};

/**
 * Validate custom attributes
 *
 * @param  {String} name  The boolean attribute name to set.
 */
 let validateAttribute = ( name ) => {

    if ( validatedAttributeNameCache[name] ) {
        return true;
    }

    if ( illegalAttributeNameCache[name] ) {
        return false;
    }
     // namespace attributes are seen as non-valid, avoid that!
     if ( VALID_ATTRIBUTE_NAME_REGEX.test( name ) || 
	    ( xmlMap[name] ) || 
		( xlinkMap[name] ) ) {
			
        validatedAttributeNameCache[name] = true;
        return true;
    }

    illegalAttributeNameCache[name] = true;

    return false;
};

/**
 * Set boolean attributes
 *
 * @param  {Object} node A DOM element.
 * @param  {String} name  The boolean attribute name to set.
 * @param {String} value The boolean attribute value to set.
 */
let setBooleanAttribute = (node, name, value) => {
	// Avoid touching the DOM and set falsy attributes.
	if (value !== false) {
		node.setAttribute(name, '' + (value === true ? '' : value));
	}
};

/**
 * Set Inferno attributes
 *
 * @param  {Object} node A DOM element.
 * @param  {String} name  The attribute name to set.
 * @param {String} value The attribute value to set.
 */
let setInfernoAttribute = (node, name, value) => {
	node.setAttribute(name, value);
};

/**
 * Set custom attributes on a DOM node
 *
 * @param {Object} node A DOM element.
 * @param {String} name	 The attribute name to set.
 * @param {String} value  The attribute value to set.
 */
{'fraction_non_alphanumeric': 0.15876698707325157, 'fraction_numerical': 0.00033145508783559825, 'mean_word_length': 3.3731884057971016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '7193825', 'n_tokens_mistral': 1992, 'n_tokens_neox': 1961, 'n_words': 597}