All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.lib.dom-utils.getScrollParent.js Maven / Gradle / Ivy

There is a newer version: 2.11.8
Show newest version
import getParentNode from "./getParentNode.js";
import isScrollParent from "./isScrollParent.js";
import getNodeName from "./getNodeName.js";
import { isHTMLElement } from "./instanceOf.js";
export default function getScrollParent(node) {
  if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
    // $FlowFixMe[incompatible-return]: assume body is always available
    return node.ownerDocument.body;
  }

  if (isHTMLElement(node) && isScrollParent(node)) {
    return node;
  }

  return getScrollParent(getParentNode(node));
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy