<commit_before>%x{
  var root = $opal.global, dom_class;

  if (root.jQuery) {
    dom_class = jQuery
  }
  else if (root.Zepto) {
    dom_class = Zepto.zepto.Z;
  }
  else {
    throw new Error("jQuery must be included before opal-jquery");
  }
}

class Element < `dom_class`
  include Enumerable

  def self.find(selector)
    `$(#{selector})`
  end

  def self.[](selector)
    `$(#{selector})`
  end

  def self.id(id)
    %x{
      var el = document.getElementById(id);

      if (!el) {
        return nil;
      }

      return $(el);
    }
  end

  def self.new(tag = 'div')
    `$(document.createElement(tag))`
  end

  def self.parse(str)
    `$(str)`
  end

  def self.expose(*methods)
    %x{
      for (var i = 0, length = methods.length, method; i < length; i++) {
        method = methods[i];
        self._proto['$' + method] = self._proto[method];
      }

      return nil;
    }
  end

  attr_reader :selector

  # Bridged functions - we just expose all core jquery functions as ruby
  # methods on this class.
  expose :after, :before, :parent, :parents, :prepend, :prev, :remove
  expose :hide, :show, :toggle, :children, :blur, :closest, :data
  expose :focus, :find, :next, :siblings, :text, :trigger, :append
  expose :height, :width, :serialize, :is, :filter, :last, :first
  expose :wrap, :stop, :clone, :empty
  expose :get, :attr, :prop

  # We alias some jquery methods to common ruby method names.
  alias succ next
  alias << append

  # Here we map the remaining jquery methods, but change their names to
  # snake_case to be more consistent with ruby.
  alias_native :[]=, :attr
  alias_native :add_class, :addClass
  alias_native :append_to, :appendTo
  alias_native :has_class?, :hasClass
  alias_native :html=, :html
  alias_native :remove_attr, :removeAttr
  alias_native :remove_class, :removeClass
  alias_native :text=, :text
  alias_native :toggle_class, :toggleClass
  alias_native :value=, :val
  alias_native :scroll_left=, :scrollLeft
  alias_native :scroll_left, :scrollLeft
  alias_native :remove_attribute, :removeAttr
  alias_native :slide_down, :slideDown
  alias_native :slide_up, :slideUp
  alias_native :slide_toggle, :slideToggle
  alias_native :fade_toggle, :fadeToggle

  def to_n
    self
  end
  
  def [](name)
    `self.attr(name) || ""`
  end

  def add_attribute name<commit_msg>whitespace<commit_after>%x{
  var root = $opal.global, dom_class;

  if (root.jQuery) {
    dom_class = jQuery
  }
  else if (root.Zepto) {
    dom_class = Zepto.zepto.Z;
  }
  else {
    throw new Error("jQuery must be included before opal-jquery");
  }
}

class Element < `dom_class`
  include Enumerable

  def self.find(selector)
    `$(#{selector})`
  end

  def self.[](selector)
    `$(#{selector})`
  end

  def self.id(id)
    %x{
      var el = document.getElementById(id);

      if (!el) {
        return nil;
      }

      return $(el);
    }
  end

  def self.new(tag = 'div')
    `$(document.createElement(tag))`
  end

  def self.parse(str)
    `$(str)`
  end

  def self.expose(*methods)
    %x{
      for (var i = 0, length = methods.length, method; i < length; i++) {
        method = methods[i];
        self._proto['$' + method] = self._proto[method];
      }

      return nil;
    }
  end

  attr_reader :selector

  # Bridged functions - we just expose all core jquery functions as ruby
  # methods on this class.
  expose :after, :before, :parent, :parents, :prepend, :prev, :remove
  expose :hide, :show, :toggle, :children, :blur, :closest, :data
  expose :focus, :find, :next, :siblings, :text, :trigger, :append
  expose :height, :width, :serialize, :is, :filter, :last, :first
  expose :wrap, :stop, :clone, :empty
  expose :get, :attr, :prop

  # We alias some jquery methods to common ruby method names.
  alias succ next
  alias << append

  # Here we map the remaining jquery methods, but change their names to
  # snake_case to be more consistent with ruby.
  alias_native :[]=, :attr
  alias_native :add_class, :addClass
  alias_native :append_to, :appendTo
  alias_native :has_class?, :hasClass
  alias_native :html=, :html
  alias_native :remove_attr, :removeAttr
  alias_native :remove_class, :removeClass
  alias_native :text=, :text
  alias_native :toggle_class, :toggleClass
  alias_native :value=, :val
  alias_native :scroll_left=, :scrollLeft
  alias_native :scroll_left, :scrollLeft
  alias_native :remove_attribute, :removeAttr
  alias_native :slide_down, :slideDown
  alias_native :slide_up, :slideUp
  alias_native :slide_toggle, :slideToggle
  alias_native :fade_toggle, :fadeToggle

  def to_n
    self
  end

  def [](name)
    `self.attr(name) || ""`
  end

  def add_attribute name
{'fraction_non_alphanumeric': 0.12443874278383579, 'fraction_numerical': 0.00042762454564892024, 'mean_word_length': 3.351627906976744, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '5420280', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1592, 'n_words': 463}