ソースを参照

don't override Element#getBoundingClientRect with undefined

Gildas 7 年 前
コミット
0fe9a1f0e4
1 ファイル変更6 行追加4 行削除
  1. 6 4
      lib/lazy/web-lazy-loader-after.js

+ 6 - 4
lib/lazy/web-lazy-loader-after.js

@@ -22,9 +22,11 @@
 
 (() => {
 
-	Element.prototype.getBoundingClientRect = window._singleFile_getBoundingClientRect;
-	delete window._singleFile_getBoundingClientRect;
-	scrollBy(0, 1);
-	requestAnimationFrame(() => scrollBy(0, -1));
+	if (window._singleFile_getBoundingClientRect) {
+		Element.prototype.getBoundingClientRect = window._singleFile_getBoundingClientRect;
+		delete window._singleFile_getBoundingClientRect;
+		scrollBy(0, 1);
+		requestAnimationFrame(() => scrollBy(0, -1));
+	}
 
 })();