<commit_before>
import * as dom from './dom.js';

export {eventManager};

window.Handsontable = window.Handsontable || {};
// used to debug memory leaks
Handsontable.countEventManagerListeners = 0;
// support for older versions of Handsontable
Handsontable.eventManager = eventManager;

function eventManager(instance) {
  if (!instance) {
    throw new Error ('instance not defined');
  }

  if (!instance.eventListeners) {
    instance.eventListeners = [];
  }

  function extendEvent(event) {
    var
      componentName = 'HOT-TABLE',
      isHotTableSpotted,
      fromElement,
      realTarget,
      target,
      len;

    event.isTargetWebComponent = false;
    event.realTarget = event.target;

    if (!Handsontable.eventManager.isHotTableEnv) {
      return event;
    }
    event = dom.polymerWrap(event);
    len = event.path.length;

    while (len --) {
      if (event.path[len].nodeName === componentName) {
        isHotTableSpotted = true;

      } else if (isHotTableSpotted && event.path[len].shadowRoot) {
        target = event.path[len];

        break;
      }
      if (len === 0 && !target) {
        target = event.path[len];
      }
    }
    if (!target) {
      target = event.target;
    }
    event.isTargetWebComponent = true;

    if (dom.isWebComponentSupportedNatively()) {
      event.realTarget = event.srcElement || event.toElement;

    } else if (instance instanceof Handsontable.Core || instance instanceof Walkontable) {
      // Polymer doesn't support `event.target` property properly we must emulate it ourselves
      if (instance instanceof Handsontable.Core) {<commit_msg>Fix null MouseEvent path on safari<commit_after>
import * as dom from './dom.js';

export {eventManager};

window.Handsontable = window.Handsontable || {};
// used to debug memory leaks
Handsontable.countEventManagerListeners = 0;
// support for older versions of Handsontable
Handsontable.eventManager = eventManager;

function eventManager(instance) {
  if (!instance) {
    throw new Error ('instance not defined');
  }

  if (!instance.eventListeners) {
    instance.eventListeners = [];
  }

  function extendEvent(event) {
    var
      componentName = 'HOT-TABLE',
      isHotTableSpotted,
      fromElement,
      realTarget,
      target,
      len;

    event.isTargetWebComponent = false;
    event.realTarget = event.target;

    if (!Handsontable.eventManager.isHotTableEnv) {
      return event;
    }
    event = dom.polymerWrap(event);
    len = event.path ? event.path.length : 0;

    while (len --) {
      if (event.path[len].nodeName === componentName) {
        isHotTableSpotted = true;

      } else if (isHotTableSpotted && event.path[len].shadowRoot) {
        target = event.path[len];

        break;
      }
      if (len === 0 && !target) {
        target = event.path[len];
      }
    }
    if (!target) {
      target = event.target;
    }
    event.isTargetWebComponent = true;

    if (dom.isWebComponentSupportedNatively()) {
      event.realTarget = event.srcElement || event.toElement;

    } else if (instance instanceof Handsontable.Core || instance instanceof Walkontable) {
      // Polymer doesn't support `event.target` property properly we must emulate it ourselves
      if (instance instanceof Handsontable.Core) {
{'fraction_non_alphanumeric': 0.11236297198538368, 'fraction_numerical': 0.0015225334957369061, 'mean_word_length': 2.8692579505300353, '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': '1735079', 'n_tokens_mistral': 989, 'n_tokens_neox': 957, 'n_words': 235}