<commit_before>import {
  connected as $connected,
  created as $created,
  props as $props,
  renderer as $renderer,
  rendererDebounced as $rendererDebounced,
} from '../util/symbols';
import { customElementsV0 } from '../util/support';
import data from '../util/data';
import debounce from '../util/debounce';
import getAllKeys from '../util/get-all-keys';
import getOwnPropertyDescriptors from '../util/get-own-property-descriptors';

const setElementAsDefined = elem => elem.setAttribute('defined', '');
const hasReflect = 'Reflect' in window;

function callConstructor(elem) {
  const elemData = data(elem);
  const readyCallbacks = elemData.readyCallbacks;
  const Ctor = elem.constructor;
  const { created, observedAttributes, props } = Ctor;

  // Ensures that this can never be called twice.
  if (elem[$created]) return;
  elem[$created] = true;

  // Set up a renderer that is debounced for property sets to call directly.
  elem[$rendererDebounced] = debounce(Ctor[$renderer]);

  if (props && Ctor[$props]) {
    Ctor[$props](elem);
  }

  if (created) {
    created(elem);
  }

  if (readyCallbacks) {
    readyCallbacks.forEach(cb => cb(elem));
    delete elemData.readyCallbacks;
  }

  // In v0 we must ensure the attributeChangedCallback is called for attrs
  // that aren't linked to props so that the callback behaves the same no
  // matter if v0 or v1 is being used.
  if (customElementsV0) {
    observedAttributes.forEach((name) => {
      const propertyName = data(elem, 'attributeLinks')[name];
      if (!propertyName) {
        elem.attributeChangedCallback(name, null, elem.getAttribute(name));
      }
    });
  }
}

function callConnected(elem) {
  const ctor = elem.constructor;
  const { attached } = ctor;
  const render = ctor[$renderer];
  elem[$connected] = true;
  if (typeof render === 'function') {
    render(elem);
  }
  if (typeof attached === 'function') {
    attached(elem);
  }
}

function callDisconnected(elem) {
  const { detached } = elem.constructor;
  elem[$connected] = false;
  if (typeof detached === 'function') {
    detached(elem);
  }
}

// v1
function Component(...args) {
  const elm = (hasReflect && Reflect.construct(HTMLElement, args, this.constructor)) || HTMLElement.call(this, args[0]);
  callConstructor(elm);
  return elm;
}

// v1
Component.observedAttributes = [];

// Skate
Component.props = {};

// Skate
Component.extend = function extend(definition = {}, Base = this) {
  // Create class for the user.
  class Ctor extends Base {}

  // Pass on statics from the Base if not supported (IE 9 and 10).<commit_msg>refactor: elm -> elem and ternary<commit_after>import {
  connected as $connected,
  created as $created,
  props as $props,
  renderer as $renderer,
  rendererDebounced as $rendererDebounced,
} from '../util/symbols';
import { customElementsV0 } from '../util/support';
import data from '../util/data';
import debounce from '../util/debounce';
import getAllKeys from '../util/get-all-keys';
import getOwnPropertyDescriptors from '../util/get-own-property-descriptors';

const setElementAsDefined = elem => elem.setAttribute('defined', '');
const hasReflect = 'Reflect' in window;

function callConstructor(elem) {
  const elemData = data(elem);
  const readyCallbacks = elemData.readyCallbacks;
  const Ctor = elem.constructor;
  const { created, observedAttributes, props } = Ctor;

  // Ensures that this can never be called twice.
  if (elem[$created]) return;
  elem[$created] = true;

  // Set up a renderer that is debounced for property sets to call directly.
  elem[$rendererDebounced] = debounce(Ctor[$renderer]);

  if (props && Ctor[$props]) {
    Ctor[$props](elem);
  }

  if (created) {
    created(elem);
  }

  if (readyCallbacks) {
    readyCallbacks.forEach(cb => cb(elem));
    delete elemData.readyCallbacks;
  }

  // In v0 we must ensure the attributeChangedCallback is called for attrs
  // that aren't linked to props so that the callback behaves the same no
  // matter if v0 or v1 is being used.
  if (customElementsV0) {
    observedAttributes.forEach((name) => {
      const propertyName = data(elem, 'attributeLinks')[name];
      if (!propertyName) {
        elem.attributeChangedCallback(name, null, elem.getAttribute(name));
      }
    });
  }
}

function callConnected(elem) {
  const ctor = elem.constructor;
  const { attached } = ctor;
  const render = ctor[$renderer];
  elem[$connected] = true;
  if (typeof render === 'function') {
    render(elem);
  }
  if (typeof attached === 'function') {
    attached(elem);
  }
}

function callDisconnected(elem) {
  const { detached } = elem.constructor;
  elem[$connected] = false;
  if (typeof detached === 'function') {
    detached(elem);
  }
}

// v1
function Component(...args) {
  const elem = hasReflect ?
    Reflect.construct(HTMLElement, args, this.constructor) :
    HTMLElement.call(this, args[0]);
  callConstructor(elem);
  return elem;
}

// v1
Component.observedAttributes = [];

// Skate
Component.props = {};

// Skate
Component.extend = function extend(definition = {}, Base = this) {
  // Create class for the user.
  class Ctor extends Base {}

  // Pass on statics from the Base if not supported (IE 9 and 10).
{'fraction_non_alphanumeric': 0.13357678262540842, 'fraction_numerical': 0.004228329809725159, 'mean_word_length': 3.6756513926325245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '2317648', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1590, 'n_words': 461}