<commit_before>var utils = require('./utils');
var dom = require('./dom-helper');
var Dropdown = require('./dropdown');

function AutoComplete(container, entries, opt) {
  var self = this;

  // Check params at first
  if (!container)
    throw new Error('You must assign an element to render on page!');
  if (!entries || entries.length === 0)
    throw new Error('Entries must be an non-empty array!');

  // Internal option object
  this._opt = {
    searchResultsToShow: (opt && opt.searchResultsToShow) || 5,
    onTagsUpdate: opt && opt.onTagsUpdate
  };
  // Internal state object
  this._state = {
    tags: [],
    entries: entries
  };
  // Interval DOM references
  this.dom = {
    rootContainerNode: this._createRootContainer(),
    tagsContainerNode: this._createTagsContainer(),
    inputNode: this._createInputBox()
  };
  this.dom.rootContainerNode.appendChild(this.dom.tagsContainerNode);
  this.dom.rootContainerNode.appendChild(this.dom.inputNode);

  // Create dropdown menu
  this.dropdown = new Dropdown([], {
    onItemClick: function(item) {
      self._onTagSelect(item.value);
    }
  });

  this._initializeEventHandlers();

  // Replace target container with a brand new root-container
  dom.renderTo(this.dom.rootContainerNode, container);
  // Render dropdown to the input element
  this.dropdown.renderTo(this.dom.rootContainerNode);<commit_msg>Fix the issue when callback not given<commit_after>var utils = require('./utils');
var dom = require('./dom-helper');
var Dropdown = require('./dropdown');

function AutoComplete(container, entries, opt) {
  var self = this;

  // Check params at first
  if (!container)
    throw new Error('You must assign an element to render on page!');
  if (!entries || entries.length === 0)
    throw new Error('Entries must be an non-empty array!');

  // Internal option object
  this._opt = {
    searchResultsToShow: (opt && opt.searchResultsToShow) || 5,
    onTagsUpdate: (opt && opt.onTagsUpdate) || function() {}
  };
  // Internal state object
  this._state = {
    tags: [],
    entries: entries
  };
  // Interval DOM references
  this.dom = {
    rootContainerNode: this._createRootContainer(),
    tagsContainerNode: this._createTagsContainer(),
    inputNode: this._createInputBox()
  };
  this.dom.rootContainerNode.appendChild(this.dom.tagsContainerNode);
  this.dom.rootContainerNode.appendChild(this.dom.inputNode);

  // Create dropdown menu
  this.dropdown = new Dropdown([], {
    onItemClick: function(item) {
      self._onTagSelect(item.value);
    }
  });

  this._initializeEventHandlers();

  // Replace target container with a brand new root-container
  dom.renderTo(this.dom.rootContainerNode, container);
  // Render dropdown to the input element
  this.dropdown.renderTo(this.dom.rootContainerNode);
{'fraction_non_alphanumeric': 0.12870933142652843, 'fraction_numerical': 0.0014301036825169824, 'mean_word_length': 3.7747440273037545, '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': '3263784', 'n_tokens_mistral': 813, 'n_tokens_neox': 796, 'n_words': 210}