<commit_before>const vdom = () => {
  const setProp = (element, attribute, original, updated) => {
    if (attribute === 'value') {
      if (updated || updated === 0 || updated === '') { element[attribute] = updated; }
      return;
    }

    if (typeof updated === 'boolean') {
      if (updated) {
        element.setAttribute(attribute, updated);
        element[attribute] = updated;
      }
      return;
    }

    if (typeof updated === 'function') {
      try {
        element[attribute] = updated;
        return;
      } catch (e) {
        return;
      }
    }

    if (!updated || (typeof updated === 'object' && !Object.keys(updated).length)) {
      element.removeAttribute(attribute);
      return;
    }

    if (attribute === 'style') {
      const updatedStyles = updated || {};
      const originalStyles = original || {};
      const styles = new Set(Object.keys(updatedStyles), Object.keys(originalStyles));

      for (const style of styles) {
        if (!updatedStyles[style]) { element.style[style] = ''; } else if (!originalStyles[style] || originalStyles[style] !== updatedStyles[style]) {
          element.style[style] = updated[style];
        }
      }

      return;
    }

    element.setAttribute(attribute, updated);
  };

  const setProps = (element, props) => {
    for (const [attribute, value] of Object.entries(props)) {
      setProp(element, attribute, {}, value);
    }
  };

  const createElement = (node) => {
    if (typeof node === 'string') {
      return document.createTextNode(node);
    }

    const { type, props, children } = node;
    const element = document.createElement(type);
    setProps(element, props);

    children
      .map(createElement)
      .forEach(child => element.appendChild(child));

    return element;
  };

  const shouldReplace = (original, updated) =>
    typeof original !== typeof updated ||
    (typeof original === 'string' && original !== updated) ||
    original.type !== updated.type;

  const updateProps = (element, original, updated) => {
    const props = new Set();

    for (const key of Object.keys(original)) {
      props.add(key || '');
    }

    for (const key of Object.keys(updated)) {
      props.add(key || '');
    }

    for (const prop of props) {
      setProp(element, prop, original[prop], updated[prop]);
    }
  };

  const reconcile = (parent, element, previous, next) => {
    if (!previous) {
      const el = createElement(next);

      if (next.props.oncreate) {<commit_msg>found a better way to handle merging of props courtesy of anthlubic<commit_after>const vdom = () => {
  const setProp = (element, attribute, original, updated) => {
    if (attribute === 'value') {
      if (updated || updated === 0 || updated === '') { element[attribute] = updated; }
      return;
    }

    if (typeof updated === 'boolean') {
      if (updated) {
        element.setAttribute(attribute, updated);
        element[attribute] = updated;
      }
      return;
    }

    if (typeof updated === 'function') {
      try {
        element[attribute] = updated;
        return;
      } catch (e) {
        return;
      }
    }

    if (!updated || (typeof updated === 'object' && !Object.keys(updated).length)) {
      element.removeAttribute(attribute);
      return;
    }

    if (attribute === 'style') {
      const updatedStyles = updated || {};
      const originalStyles = original || {};
      const styles = new Set(Object.keys(updatedStyles), Object.keys(originalStyles));

      for (const style of styles) {
        if (!updatedStyles[style]) {
          element.style[style] = '';
        } else if (!originalStyles[style] || originalStyles[style] !== updatedStyles[style]) {
          element.style[style] = updated[style];
        }
      }

      return;
    }

    element.setAttribute(attribute, updated);
  };

  const setProps = (element, props) => {
    for (const [attribute, value] of Object.entries(props)) {
      setProp(element, attribute, {}, value);
    }
  };

  const createElement = (node) => {
    if (typeof node === 'string') {
      return document.createTextNode(node);
    }

    const { type, props, children } = node;
    const element = document.createElement(type);
    setProps(element, props);

    children
      .map(createElement)
      .forEach(child => element.appendChild(child));

    return element;
  };

  const shouldReplace = (original, updated) =>
    typeof original !== typeof updated ||
    (typeof original === 'string' && original !== updated) ||
    original.type !== updated.type;

  const updateProps = (element, original, updated) => {
    const merged = [...Object.keys(original), ...Object.keys(updated)];
    const props = new Set(merged);

    for (const prop of props) {
      setProp(element, prop, original[prop], updated[prop]);
    }
  };

  const reconcile = (parent, element, previous, next) => {
    if (!previous) {
      const el = createElement(next);

      if (next.props.oncreate) {
{'fraction_non_alphanumeric': 0.1525015069318867, 'fraction_numerical': 0.0004018485031143259, 'mean_word_length': 2.646886446886447, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '6663227', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1390, 'n_words': 357}