<commit_before>import { options, render } from 'preact';

const mapDom = new WeakMap();
const mapNodeName = new WeakMap();
let oldVnode;

function generateUniqueName(prefix) {
  let suffix = 0;
  while (customElements.get(prefix + suffix)) ++suffix;
  return `${prefix}-${suffix}`;
}

function newVnode(vnode) {
  let fn = vnode.nodeName;
  if (fn && fn.prototype instanceof HTMLElement) {
    let nodeName = mapNodeName.get(fn);
    if (!nodeName) {
      nodeName = generateUniqueName(fn.name.toLowerCase());
      mapNodeName.set(fn, nodeName);
      customElements.define(nodeName, class extends fn {});
    }
    vnode.nodeName = nodeName;
  }
  return vnode;
}

function setupPreact() {
  oldVnode = options.vnode;
  options.vnode = newVnode;
}

function teardownPreact() {
  options.vnode = oldVnode;
}<commit_msg>Fix issue causing preact renderer to invoke an infinite loop.<commit_after>import { options, render } from 'preact';

const mapDom = new WeakMap();
const mapNodeName = new WeakMap();
let oldVnode;

function generateUniqueName(prefix) {
  let suffix = 0;
  while (customElements.get(`${prefix}-${suffix}`)) ++suffix;
  return `${prefix}-${suffix}`;
}

function newVnode(vnode) {
  let fn = vnode.nodeName;
  if (fn && fn.prototype instanceof HTMLElement) {
    let nodeName = mapNodeName.get(fn);
    if (!nodeName) {
      nodeName = generateUniqueName(fn.name.toLowerCase());
      mapNodeName.set(fn, nodeName);
      customElements.define(nodeName, class extends fn {});
    }
    vnode.nodeName = nodeName;
  }
  return vnode;
}

function setupPreact() {
  oldVnode = options.vnode;
  options.vnode = newVnode;
}

function teardownPreact() {
  options.vnode = oldVnode;
}
{'fraction_non_alphanumeric': 0.13266509433962265, 'fraction_numerical': 0.0011792452830188679, 'mean_word_length': 4.11144578313253, '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': '655693', 'n_tokens_mistral': 570, 'n_tokens_neox': 568, 'n_words': 134}