Просмотр исходного кода

check if the root element exists before calling getBoundingClientRect

Gildas 7 лет назад
Родитель
Сommit
fd2530f703
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      lib/hooks/hooks-frame.js

+ 1 - 1
lib/hooks/hooks-frame.js

@@ -113,7 +113,7 @@ this.hooksFrame = this.hooksFrame || (() => {
 			addEventListener(LOAD_OBSERVED_ELEMENTS_EVENT, () => {
 				const docBoundingRect = document.documentElement.getBoundingClientRect();
 				Array.from(observers).forEach(([intersectionObserver, observer]) => {
-					const rootBoundingRect = observer.options.root.getBoundingClientRect();
+					const rootBoundingRect = observer.options.root && observer.options.root.getBoundingClientRect();
 					observer.callback(observedElements.get(intersectionObserver).map(target => {
 						const boundingClientRect = target.getBoundingClientRect();
 						const isIntersecting = true;