<commit_before>// @flow
/**
 * Binds the callback to the element at the event and the selector.
 * @param {HTMLElement} el The element
 * @param {string} event The event
 * @param {?string} selector The selector
 * @param {Function} callback The handler
 */
export default (el: HTMLElement, event: string, selector: ?string, callback: ((e: Event) => void)) => {
  el.addEventListener(event, (e: Event): void => {
    if (!selector) {
      callback(e)
      return
    }

    const nodes = el.querySelectorAll(selector)
    const target: HTMLElement = (e.target: any)

    for (let i = 0; i < nodes.length; i++) {
      if (nodes[i] === target || nodes[i].contains(target)) {
        callback(e)
        return
      }
    }
  })
}<commit_msg>:hammer: refactor(event-deleagte): save bytes<commit_after>// @flow
/**
 * Binds the callback to the element at the event and the selector.
 * @param {HTMLElement} el The element
 * @param {string} event The event
 * @param {?string} selector The selector
 * @param {Function} callback The handler
 */
export default (el: HTMLElement, event: string, selector: ?string, callback: ((e: Event) => void)) => {
  el.addEventListener(event, (e: Event): void => {
    selector ? [].some.call(el.querySelectorAll(selector), node => {
      if (node === e.target || node.contains(e.target)) {
        callback(e)
        return 1
      }
    }) : callback(e)
  })
}
{'fraction_non_alphanumeric': 0.15153681200857755, 'fraction_numerical': 0.0014295925661186562, 'mean_word_length': 3.216867469879518, 'pattern_counts': {'":': 0, '<': 4, '<?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': '5410118', 'n_tokens_mistral': 433, 'n_tokens_neox': 433, 'n_words': 139}