<commit_before>#
# Defines the basic dom-element wrapper
#
# Copyright (C) 2011 <NAME>
#
Element = new Class Wrapper,
  extend:
    Wrappers: {} # custom dom-wrappers registry

  #
  # Basic constructor
  #
  # @param {String|HTMLElement} tag name or a raw dom-element
  # @param {Object} new element options
  # @return {Element} instance
  #
  constructor: (element, options) ->
    element = make_element(element, options) if typeof(element) is 'string'

    # handling dynamic typecasting
    cast = Wrapper.Cast(element) if @constructor is Element
    return new cast(element, options) if cast isnt undefined

    this.$super(element)

    if options isnt undefined
        for key of options
          switch key
            when 'id'    then this._.id        = options[key]
            when 'html'  then this._.innerHTML = options[key]
            when 'class' then this._.className = options[key]
            when 'css'   then this.css           options[key]
            when 'on'    then this.on            options[key]
            else              this.attr     key, options[key]

    return this



# private

# a quick elements creation helper
elements_cache = {}
make_element = (tag, options) ->
  unless tag of elements_cache
    elements_cache[tag] = document.createElement(tag)<commit_msg>Code formatting fix<commit_after>#
# Defines the basic dom-element wrapper
#
# Copyright (C) 2011 <NAME>
#
Element = new Class Wrapper,
  extend:
    Wrappers: {} # custom dom-wrappers registry

  #
  # Basic constructor
  #
  # @param {String|HTMLElement} tag name or a raw dom-element
  # @param {Object} new element options
  # @return {Element} instance
  #
  constructor: (element, options) ->
    element = make_element(element, options) if typeof(element) is 'string'

    # handling dynamic typecasting
    cast = Wrapper.Cast(element) if @constructor is Element
    return new cast(element, options) if cast isnt undefined

    this.$super(element)

    if options isnt undefined
      for key of options
        switch key
          when 'id'    then this._.id        = options[key]
          when 'html'  then this._.innerHTML = options[key]
          when 'class' then this._.className = options[key]
          when 'css'   then this.css           options[key]
          when 'on'    then this.on            options[key]
          else              this.attr     key, options[key]

    return this



# private

# a quick elements creation helper
elements_cache = {}
make_element = (tag, options) ->
  unless tag of elements_cache
    elements_cache[tag] = document.createElement(tag)
{'fraction_non_alphanumeric': 0.09069946195234435, 'fraction_numerical': 0.0030745580322828594, 'mean_word_length': 2.5318860244233377, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2944010', 'n_tokens_mistral': 746, 'n_tokens_neox': 725, 'n_words': 245}