Skip to content

Commit ca6674c

Browse files
author
Madeline Trotter
committed
Fix recursive path in getScrollParent
1 parent d0e4388 commit ca6674c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Lumi/Components2/ScrollObserver.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
// the first parent with a scroll bar (including auto, which
55
// on some devices hides the scroll bar until hovered).
66
exports.getScrollParent = node => () => {
7-
const isElement = node instanceof HTMLElement;
8-
const computedStyle = isElement && window.getComputedStyle(node);
7+
if (!(node instanceof HTMLElement)) {
8+
return document.body;
9+
}
10+
11+
const computedStyle = window.getComputedStyle(node);
912
const overflowY = computedStyle && computedStyle.overflowY;
1013
const overflowX = computedStyle && computedStyle.overflowX;
1114
const isScrollable =
@@ -14,12 +17,10 @@ exports.getScrollParent = node => () => {
1417
(overflowX &&
1518
!(overflowX.includes("visible") || overflowX.includes("hidden")));
1619

17-
if (!node) {
18-
return document.body;
19-
} else if (isScrollable && node.scrollHeight >= node.clientHeight) {
20+
if (isScrollable && node.scrollHeight >= node.clientHeight) {
2021
return node;
2122
} else {
22-
return exports.getScrollParent(node.parentNode);
23+
return exports.getScrollParent(node.parentNode)();
2324
}
2425
};
2526

0 commit comments

Comments
 (0)