<commit_before>import $ from './../common/util/dom/$'
import makeElement from './../common/util/dom/make-element'
import setAttribute from './../common/util/dom/set-attribute'
import { WIN } from './../common/global-variables'

let styleNode
// Create cache and shortcut to the correct property
let cssTextProp
let byName = {}
let remainder = []
let needsInject = false

// skip the following code on the server
if (WIN) {
  styleNode = ((() => {
    // create a new style element with the correct type
    const newNode = makeElement('style')
    // replace any user node or insert the new one into the head
    const userNode = $('style[type=riot]')

    setAttribute(newNode, 'type', 'text/css')
    /* istanbul ignore next */
    if (userNode) {
      if (userNode.id) newNode.id = userNode.id
      userNode.parentNode.replaceChild(newNode, userNode)
    } else document.head.appendChild(newNode)

    return newNode
  }))()
  cssTextProp = styleNode.styleSheet
}

/**
 * Object that will be used to inject and manage the css of every tag instance
 */
export default {
  styleNode,
  /**
   * Save a tag style to be later injected into DOM
   * @param { String } css - css string
   * @param { String } name - if it's passed we will map the css to a tagname
   */
  add(css, name) {
    if (name) byName[name] = css
    else remainder.push(css)
    needsInject = true
  },
  /**
   * Inject all previously saved tag styles into DOM
   * innerHTML seems slow: http://jsperf.com/riot-insert-style
   */
  inject() {
    if (!WIN || !needsInject) return
    needsInject = false
    const style = Object.keys(byName)
      .map(k => byName[k])
      .concat(remainder).join('\n')
    /* istanbul ignore next */
    if (cssTextProp) cssTextProp.cssText = style
    else styleNode.innerHTML = style
  },

  /**
   * Remove a tag style of injected DOM later.
   * @param {String} name a registered tagname
   */<commit_msg>removed: unnecessary internal logic for the css injection<commit_after>import $ from './../common/util/dom/$'
import makeElement from './../common/util/dom/make-element'
import setAttribute from './../common/util/dom/set-attribute'
import { WIN } from './../common/global-variables'

let styleNode
// Create cache and shortcut to the correct property
let cssTextProp
let byName = {}
let needsInject = false

// skip the following code on the server
if (WIN) {
  styleNode = ((() => {
    // create a new style element with the correct type
    const newNode = makeElement('style')
    // replace any user node or insert the new one into the head
    const userNode = $('style[type=riot]')

    setAttribute(newNode, 'type', 'text/css')
    /* istanbul ignore next */
    if (userNode) {
      if (userNode.id) newNode.id = userNode.id
      userNode.parentNode.replaceChild(newNode, userNode)
    } else document.head.appendChild(newNode)

    return newNode
  }))()
  cssTextProp = styleNode.styleSheet
}

/**
 * Object that will be used to inject and manage the css of every tag instance
 */
export default {
  styleNode,
  /**
   * Save a tag style to be later injected into DOM
   * @param { String } css - css string
   * @param { String } name - if it's passed we will map the css to a tagname
   */
  add(css, name) {
    byName[name] = css
    needsInject = true
  },
  /**
   * Inject all previously saved tag styles into DOM
   * innerHTML seems slow: http://jsperf.com/riot-insert-style
   */
  inject() {
    if (!WIN || !needsInject) return
    needsInject = false
    const style = Object.keys(byName)
      .map(k => byName[k])
      .join('\n')
    /* istanbul ignore next */
    if (cssTextProp) cssTextProp.cssText = style
    else styleNode.innerHTML = style
  },

  /**
   * Remove a tag style of injected DOM later.
   * @param {String} name a registered tagname
   */
{'fraction_non_alphanumeric': 0.12125984251968504, 'fraction_numerical': 0.0, 'mean_word_length': 2.872967479674797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5263084', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1149, 'n_words': 395}