'use strict';

function getScrollParent(element) {
  if (!element) return null;
  const overflowRegex = /(auto|scroll)/;
  let parent = element.parentElement;
  while (parent) {
    const style = getComputedStyle(parent);
    const overflowY = style.overflowY;
    const overflowX = style.overflowX;
    if (overflowRegex.test(overflowY) || overflowRegex.test(overflowX)) {
      return parent;
    }
    parent = parent.parentElement;
  }
  return null;
}

exports.getScrollParent = getScrollParent;
