'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var getParentNode = require('./getParentNode.js');
var isScrollParent = require('./isScrollParent.js');
var getNodeName = require('./getNodeName.js');
var instanceOf = require('./instanceOf.js');

function getScrollParent(node) {
  if (['html', 'body', '#document'].indexOf(getNodeName.default(node)) >= 0) {
    // $FlowFixMe[incompatible-return]: assume body is always available
    return node.ownerDocument.body;
  }

  if (instanceOf.isHTMLElement(node) && isScrollParent.default(node)) {
    return node;
  }

  return getScrollParent(getParentNode.default(node));
}

exports.default = getScrollParent;
//# sourceMappingURL=getScrollParent.js.map
