<commit_before>"use strict";

// props: Object
// Component: (props, children: Array<Element>, store) => null | string | Element
// Compose:
//   (component, props, children: Array<null|string|Element>) => Element

function createStore(initialState) {
  var _state = initialState || {}
  var _listeners = [];

  function updateListeners(state) {
    _listeners.forEach(function(listener) {
        listener.callback(state);
    });
  }
  return {
    setState: function(state) {
      _state = state;
      updateListeners(state);
    },

    getState: function() {
      return _state;
    },

    onUpdate: function(name, callback) {
      _listeners.push({name: name, callback: callback});
    }
  };
}

function createDomElement(elementName) {
  return function(props, children) {
    const element = document.createElement(elementName);
    if (props != null) {
      _.forEach(props, function(key, value) {
        if (key === "onSubmit") {
          element.addEventListener("submit", value);
        } else {
          element.setAttribute(key, value);
        }
      })
    }
    if (children != null) {
      children.forEach(function(child) {
        element.appendChild(child);<commit_msg>Add a todo note about missing event listeners<commit_after>"use strict";

// props: Object
// Component: (props, children: Array<Element>, store) => null | string | Element
// Compose:
//   (component, props, children: Array<null|string|Element>) => Element

function createStore(initialState) {
  var _state = initialState || {}
  var _listeners = [];

  function updateListeners(state) {
    _listeners.forEach(function(listener) {
        listener.callback(state);
    });
  }
  return {
    setState: function(state) {
      _state = state;
      updateListeners(state);
    },

    getState: function() {
      return _state;
    },

    onUpdate: function(name, callback) {
      _listeners.push({name: name, callback: callback});
    }
  };
}

function createDomElement(elementName) {
  return function(props, children) {
    const element = document.createElement(elementName);
    if (props != null) {
      _.forEach(props, function(key, value) {
        // TODO: add support for adding other kinds of event listeners
        if (key === "onSubmit") {
          element.addEventListener("submit", value);
        } else {
          element.setAttribute(key, value);
        }
      })
    }
    if (children != null) {
      children.forEach(function(child) {
        element.appendChild(child);
{'fraction_non_alphanumeric': 0.13522138013562027, 'fraction_numerical': 0.0, 'mean_word_length': 2.924882629107981, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '3881624', 'n_tokens_mistral': 708, 'n_tokens_neox': 707, 'n_words': 162}