{"size": 801, "ext": "js", "max_stars_repo_path": "node_modules/sweetalert-react/lib/utils/outsideTargetHandlerFactory.js", "max_stars_repo_name": "annelindeandersen/bachelor_project", "max_stars_repo_stars_event_min_datetime": "2018-08-14T13:05:19.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-14T13:05:19.000Z", "max_issues_repo_path": "node_modules/sweetalert-react/lib/utils/outsideTargetHandlerFactory.js", "max_issues_repo_name": "annelindeandersen/bachelor_project", "max_issues_repo_issues_event_min_datetime": "2020-09-07T14:18:57.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-08T23:02:59.000Z", "max_forks_repo_path": "node_modules/sweetalert-react/lib/utils/outsideTargetHandlerFactory.js", "max_forks_repo_name": "bkdubey/react-monitoring-tool", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 7, "max_forks_count": null, "avg_line_length": 25.03125, "max_line_length": 95, "alphanum_fraction": 0.6928838951}
'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = outsideTargetHandlerFactory;

var _isDOMEquals = require('./isDOMEquals');

var _isDOMEquals2 = _interopRequireDefault(_isDOMEquals);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 *
 * @param  {HTMLElement}  targetNode
 * @param  {HTMLElement}  eventHandler
 * @return {Boolean}
 */
function outsideTargetHandlerFactory(targetNode, eventHandler) {
  return function (evt) {
    evt.stopPropagation();
    var current = evt.target;
    var found = false;
    while (current.parentNode) {
      found = (0, _isDOMEquals2.default)(current, targetNode);
      if (found) return;
      current = current.parentNode;
    }
    eventHandler(evt);
  };
}