<commit_before>import {
  TYPE_ATTRIBUTE,
  TYPE_CLASSNAME,
  TYPE_ELEMENT
} from '../constants';

const DEFAULT_ELEMENT = 'div';

function createElement (options) {
  var element;
  var id = options.id;
  var parent = options.extends;
  var type = options.type;

  // Allow all types of components to be constructed.
  if (type === TYPE_ELEMENT) {
    element = document.createElement(parent || id);

    if (parent) {
      element.setAttribute('is', id);
    }
  } else {
    element = document.createElement(parent || DEFAULT_ELEMENT);

    if (type === TYPE_ATTRIBUTE) {
      element.setAttribute(id, '');
    } else if (type === TYPE_CLASSNAME) {
      element.className = id;
    }
  }

  return element;
}

export default function (options) {
  function CustomElement () {
    var element = createElement(options);

    // Ensure the definition prototype is up to date with the element's
    // prototype. This ensures that overwriting the element prototype still
    // works.
    options.prototype = CustomElement.prototype;

    // If they use the constructor we don't have to wait until it's attached.
    if (options.prototype.createdCallback) {
      options.prototype.createdCallback.call(element);
    }

    return element;
  }

  // This allows modifications to the element prototype propagate to the
  // definition prototype.
  CustomElement.prototype = options.prototype;

  return CustomElement;
}<commit_msg>Cleanup element constructor.<commit_after>import {
  TYPE_ATTRIBUTE,
  TYPE_CLASSNAME,
  TYPE_ELEMENT
} from '../constants';

const DEFAULT_ELEMENT = 'div';

function createElement (options) {
  var element;
  var id = options.id;
  var parent = options.extends;
  var type = options.type;

  // Allow all types of components to be constructed.
  if (type === TYPE_ELEMENT) {
    element = document.createElement(parent || id);
    if (parent) {
      element.setAttribute('is', id);
    }
  } else {
    element = document.createElement(parent || DEFAULT_ELEMENT);

    if (type === TYPE_ATTRIBUTE) {
      element.setAttribute(id, '');
    } else if (type === TYPE_CLASSNAME) {
      element.className = id;
    }
  }

  return element;
}

export default function (options) {
  function CustomElement () {
    var element = createElement(options);

    // Ensure the definition prototype is up to date with the element's
    // prototype. This ensures that overwriting the element prototype still
    // works.
    options.prototype = CustomElement.prototype;

    // Initialises. This will always exist.
    options.prototype.createdCallback.call(element);

    return element;
  }

  // This allows modifications to the element prototype propagate to the
  // definition prototype.
  CustomElement.prototype = options.prototype;

  return CustomElement;
}
{'fraction_non_alphanumeric': 0.10247223217484773, 'fraction_numerical': 0.0, 'mean_word_length': 3.217522658610272, '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': '5546151', 'n_tokens_mistral': 776, 'n_tokens_neox': 763, 'n_words': 238}