Преглед изворни кода

check if the root element exists before calling getBoundingClientRect

Gildas пре 7 година
родитељ
комит
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;