// @flow
import getParentNode from './getParentNode';
import getComputedStyle from './getComputedStyle';
import getNodeName from './getNodeName';
import { isHTMLElement } from './instanceOf';

export default function getScrollParent(node: Node): HTMLElement {
  if (!node) {
    return document.body;
  }

  if (['HTML', 'BODY', '#document'].includes(getNodeName(node))) {
    return node.ownerDocument.body;
  }

  if (isHTMLElement(node)) {
    // Firefox want us to check `-x` and `-y` variations as well
    const { overflow, overflowX, overflowY } = getComputedStyle(node);
    if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
      return node;
    }
  }

  return getScrollParent(getParentNode(node));
}

@@ -257,54 +257,8 @@
 t %7B%0A
-  if (!node) %7B%0A    return document.body;%0A  %7D%0A%0A
   if
@@ -282,16 +282,16 @@
 , '#
-document
+DOCUMENT
 '%5D.i

remove unneeded check and fix string comparison