"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const constant = require("./constant.js");
var isServerRendering = function() {
  try {
    return !(typeof window !== "undefined" && document !== void 0);
  } catch (e) {
    return true;
  }
}();
var on = function() {
  if (isServerRendering) {
    return constant.NOOP;
  }
  return function(element, event, handler, options) {
    element && element.addEventListener(event, handler, options || false);
  };
}();
var off = function() {
  if (isServerRendering) {
    return constant.NOOP;
  }
  return function(element, event, handler, options) {
    element && element.removeEventListener(event, handler, options || false);
  };
}();
var contains = function(root, ele) {
  var node = ele;
  while (node) {
    if (node === root) {
      return true;
    }
    node = node.parentNode;
  }
  return false;
};
var isScrollElement = function(element) {
  return element.scrollHeight > element.offsetHeight || element.scrollWidth > element.offsetWidth;
};
var getScrollElements = function(container, top) {
  if (top === void 0) {
    top = document.documentElement;
  }
  var scrollElements = [];
  var element = container;
  while (element && element !== top) {
    if (isScrollElement(element)) {
      scrollElements.push(element);
    }
    element = element.parentElement;
  }
  return scrollElements;
};
exports.contains = contains;
exports.getScrollElements = getScrollElements;
exports.isScrollElement = isScrollElement;
exports.isServerRendering = isServerRendering;
exports.off = off;
exports.on = on;
//# sourceMappingURL=dom.js.map
