Skip to content

Commit ce9fc7e

Browse files
committed
Add a nullcheck for the element.
1 parent e1e1842 commit ce9fc7e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/scripts/domParsers/domUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,10 @@ export module DomUtils {
944944
}
945945

946946
export function getScrollPercent(elem: Element, asDecimalValue = false) {
947+
if (!elem) {
948+
return 0;
949+
}
950+
947951
let scrollValue: number = (elem.scrollTop * 1.0) / (elem.scrollHeight - elem.clientHeight);
948952

949953
// console.warn(elem.scrollTop, elem.scrollHeight, elem.clientHeight, scrollValue);

0 commit comments

Comments
 (0)