Răsfoiți Sursa

check if the root element exists before calling getBoundingClientRect

Gildas 7 ani în urmă
părinte
comite
fd2530f703
1 a modificat fișierele cu 1 adăugiri și 1 ștergeri
  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;