<commit_before>'use babel';
import 'object-assign-shim';
import 'array.from';
import {CompositeDisposable} from 'atom';
import makeTreeViewGitBranch from './tree-view-git-branch.js';
import {addEventListener} from './utils.js';

document.registerElement('tree-view-git-branch-list', {
  extends: 'li',
  prototype: Object.assign(Object.create(HTMLElement.prototype), {
    createdCallback() {
      this.classList.add('list-nested-item', 'entry', 'directory');

      this.header = this.appendChild(document.createElement('div'));
      this.header.classList.add('header', 'list-item');

      this.label = this.header.appendChild(document.createElement('span'));
      this.label.classList.add('name', 'icon');

      this.entriesByReference = {};
      this.entries = this.appendChild(document.createElement('ol'));
      this.entries.classList.add('list-tree', 'entries');
      this.collapse();

      this.disposables = new CompositeDisposable(
        addEventListener(this.header, 'click', () =>
          this.toggleExpansion()
        )
      );
    },

    initialize({icon, title, repository, entries}) {
      this.repository = repository;
      this.setIcon(icon);
      this.setTitle(title);
      this.setEntries(entries);
    },

    destroy() {
      this.remove();
      this.disposables.dispose();
      [this.disposables, this.repository] = [];
    },

    setIcon(icon) {
      if (!icon) {
        return;
      }
      this.label.className.replace(/\bicon-[^\s]+/, '');
      this.label.classList.add(`icon-${icon}`);
    },

    setTitle(title) {
      this.title = title;
      this.label.innerHTML = title;
    },

    setEntries(references = []) {
      this.entries.innerHTML = '';
      for (let ref of references) {
        this.entries.appendChild(makeTreeViewGitBranch({
          repository: this.repository,
          ref,
        }));
      }
    },

    expand() {
      if (!this.collapsed) {
        return;
      }
      this.collapsed = false;
      this.classList.add('expanded');
      this.classList.remove('collapsed');

      this.entries.style.display = '';<commit_msg>fix memory leak<commit_after>'use babel';
import 'object-assign-shim';
import 'array.from';
import {CompositeDisposable} from 'atom';
import makeTreeViewGitBranch from './tree-view-git-branch.js';
import {addEventListener} from './utils.js';

document.registerElement('tree-view-git-branch-list', {
  extends: 'li',
  prototype: Object.assign(Object.create(HTMLElement.prototype), {
    createdCallback() {
      this.classList.add('list-nested-item', 'entry', 'directory');

      this.header = this.appendChild(document.createElement('div'));
      this.header.classList.add('header', 'list-item');

      this.label = this.header.appendChild(document.createElement('span'));
      this.label.classList.add('name', 'icon');

      this.entriesByReference = {};
      this.entries = this.appendChild(document.createElement('ol'));
      this.entries.classList.add('list-tree', 'entries');
      this.collapse();

      this.disposables = new CompositeDisposable(
        addEventListener(this.header, 'click', () =>
          this.toggleExpansion()
        )
      );
    },

    initialize({icon, title, repository, entries}) {
      this.repository = repository;
      this.setIcon(icon);
      this.setTitle(title);
      this.setEntries(entries);
    },

    destroy() {
      this.remove();
      this.disposables.dispose();
      [this.disposables, this.repository] = [];
    },

    setIcon(icon) {
      if (!icon) {
        return;
      }
      this.label.className.replace(/\bicon-[^\s]+/, '');
      this.label.classList.add(`icon-${icon}`);
    },

    setTitle(title) {
      this.title = title;
      this.label.innerHTML = title;
    },

    setEntries(references = []) {
      for (let child of Array.from(this.entries.children)) {
        child.destroy();
      }

      this.entries.innerHTML = '';
      for (let ref of references) {
        this.entries.appendChild(makeTreeViewGitBranch({
          repository: this.repository,
          ref,
        }));
      }
    },

    expand() {
      if (!this.collapsed) {
        return;
      }
      this.collapsed = false;
      this.classList.add('expanded');
      this.classList.remove('collapsed');

      this.entries.style.display = '';
{'fraction_non_alphanumeric': 0.16154379477698175, 'fraction_numerical': 0.0, 'mean_word_length': 2.6928327645051193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1664060', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1271, 'n_words': 192}