<commit_before>(function(global) {
  "use strict;"

  var VdomBuilder = function VdomBuilder(component, formId) {
    this.component = component;
    this.formId = formId;
    this.h = virtualDom.h;
    this.elements = [];
  };

  $.extend(VdomBuilder.prototype, {
    markup: function(tagName, arg1, arg2) {
      this.contentTag(tagName, arg1, arg2);
      return this.elements[0];
    },
    contentTag: function(tagName) {
      var options, content, callback, vb;

      if (typeof arguments[1] === 'string') {
        content = arguments[1];
        options = arguments[2] || {};
        attributes = generateAttributes(options);
        this.elements.push(this.h(tagName, attributes, content));
      }
      else {
        if (typeof arguments[1] === 'object') {
          options = arguments[1];
          callback = arguments[2];
        }
        else {
          options = {};
          callback = arguments[1];
        }
        if (typeof callback === 'function') {
          var vb = new VdomBuilder(this.component, this.formId);
          if (callback.length === 0) { throw new Error("Callback requires an argument.") }
          callback.call(this.component, vb);
          attributes = generateAttributes(options);
          this.elements.push(this.h(tagName, attributes, vb.elements));
        }
      }
    },
    tag: function(tagName, options) {
      attributes = generateAttributes(options);
      this.elements.push(this.h(tagName, attributes));
    },
    text: function(content) {
      this.elements.push(content);
    },
    space: function() {
      this.elements.push(' ');
    },
    form: function(name, options, callback) {
      var vb, attributes;

      if (callback.length === 0) { throw new Error("Callback requires an argument.") }
      vb = new VdomBuilder(this.component, name);
      callback.call(this.component, vb);
      options = options || {};
      options['name'] = name;
      if (options['onsubmit'] === undefined) {
        options['onsubmit'] = function(e) { return false };
      }
      attributes = generateAttributes(options);
      this.elements.push(this.h('form', attributes, vb.elements));
    },
    input: function(options) {
      var form, name, value;

      options = options || {};
      name = options['name'];
      value = options['value'];
      if (value === undefined && name !== undefined && this.formId !== undefined)
        options['value'] = this.component.getValue(this.formId, name);
      attributes = generateAttributes(options);
      this.elements.push(this.h('input', attributes));
    },
    textField: function(name, options) {
      var self = this;

      options = options || {};
      options['type'] = 'text';
      options['name'] = name;
      this.input(options);
    },
    checkBox: function(name, checked, options) {
      options = options || {};
      options['type'] = 'checkbox';
      if (name) options['name'] = name;
      if (checked) options['checked'] = 'checked';
      if (!options['value']) options['value'] = '1';
      this.input(options);
    },
    value: function(name) {
      this.component.getValue(this.formId, name);
    }
  });

  function generateAttributes(options) {
    if ('visible' in options && !options['visible']) {
      options['style'] = options['style'] || {};
      options['style']['display'] = 'none';
    }
    if (typeof options['className'] === 'object') {
      var names = []
      for (var name in options['className']) {
        if (options['className'][name]) {
          names.push(name)
        }
      }
      if (names.length) {
        options['className'] = names.join(' ')
      }
      else {
        delete options['className'];<commit_msg>Change signature of VdomBuilder#checkBox<commit_after>(function(global) {
  "use strict;"

  var VdomBuilder = function VdomBuilder(component, formId) {
    this.component = component;
    this.formId = formId;
    this.h = virtualDom.h;
    this.elements = [];
  };

  $.extend(VdomBuilder.prototype, {
    markup: function(tagName, arg1, arg2) {
      this.contentTag(tagName, arg1, arg2);
      return this.elements[0];
    },
    contentTag: function(tagName) {
      var options, content, callback, vb;

      if (typeof arguments[1] === 'string') {
        content = arguments[1];
        options = arguments[2] || {};
        attributes = generateAttributes(options);
        this.elements.push(this.h(tagName, attributes, content));
      }
      else {
        if (typeof arguments[1] === 'object') {
          options = arguments[1];
          callback = arguments[2];
        }
        else {
          options = {};
          callback = arguments[1];
        }
        if (typeof callback === 'function') {
          var vb = new VdomBuilder(this.component, this.formId);
          if (callback.length === 0) { throw new Error("Callback requires an argument.") }
          callback.call(this.component, vb);
          attributes = generateAttributes(options);
          this.elements.push(this.h(tagName, attributes, vb.elements));
        }
      }
    },
    tag: function(tagName, options) {
      attributes = generateAttributes(options);
      this.elements.push(this.h(tagName, attributes));
    },
    text: function(content) {
      this.elements.push(content);
    },
    space: function() {
      this.elements.push(' ');
    },
    form: function(name, options, callback) {
      var vb, attributes;

      if (callback.length === 0) { throw new Error("Callback requires an argument.") }
      vb = new VdomBuilder(this.component, name);
      callback.call(this.component, vb);
      options = options || {};
      options['name'] = name;
      if (options['onsubmit'] === undefined) {
        options['onsubmit'] = function(e) { return false };
      }
      attributes = generateAttributes(options);
      this.elements.push(this.h('form', attributes, vb.elements));
    },
    input: function(options) {
      var form, name, value;

      options = options || {};
      name = options['name'];
      value = options['value'];
      if (value === undefined && name !== undefined && this.formId !== undefined)
        options['value'] = this.component.getValue(this.formId, name);
      attributes = generateAttributes(options);
      this.elements.push(this.h('input', attributes));
    },
    textField: function(name, options) {
      var self = this;

      options = options || {};
      options['type'] = 'text';
      options['name'] = name;
      this.input(options);
    },
    checkBox: function(name, options) {
      var checked = this.component.getValue(this.formId, name);

      options = options || {};
      options['type'] = 'checkbox';
      if (name) options['name'] = name;
      if (checked) options['checked'] = 'checked';
      if (!options['value']) options['value'] = '1';
      this.input(options);
    },
    value: function(name) {
      this.component.getValue(this.formId, name);
    }
  });

  function generateAttributes(options) {
    if ('visible' in options && !options['visible']) {
      options['style'] = options['style'] || {};
      options['style']['display'] = 'none';
    }
    if (typeof options['className'] === 'object') {
      var names = []
      for (var name in options['className']) {
        if (options['className'][name]) {
          names.push(name)
        }
      }
      if (names.length) {
        options['className'] = names.join(' ')
      }
      else {
        delete options['className'];
{'fraction_non_alphanumeric': 0.1585349552198904, 'fraction_numerical': 0.004010159069643096, 'mean_word_length': 2.5426136363636362, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1746219', 'n_tokens_mistral': 2126, 'n_tokens_neox': 2106, 'n_words': 465}