فهرست منبع

better fix for issue #260

Former-commit-id: e8f8d8f45225cc4807931b4f24ea46b8e2763c5b
Gildas 6 سال پیش
والد
کامیت
5e07c58b1b
2فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 4 3
      lib/hooks/content/content-hooks-frames-web.js
  2. 2 1
      lib/hooks/content/content-hooks-web.js

+ 4 - 3
lib/hooks/content/content-hooks-frames-web.js

@@ -56,6 +56,7 @@
 	const requestAnimationFrame = window.requestAnimationFrame;
 	const cancelAnimationFrame = window.cancelAnimationFrame;
 	const console = window.console;
+	const warn = console.warn;
 
 	const observers = new Map();
 	const observedElements = new Map();
@@ -228,7 +229,7 @@
 	let errorDetected;
 	window.requestAnimationFrame = function (callback) {
 		if (!warningRequestAnimationFrameDisplayed) {
-			console.warn("SingleFile is hooking the requestAnimationFrame and cancelAnimationFrame functions to load deferred images in background tabs."); // eslint-disable-line no-console
+			warn.call(console, "SingleFile is hooking the requestAnimationFrame and cancelAnimationFrame functions to load deferred images in background tabs."); // eslint-disable-line no-console
 			warningRequestAnimationFrameDisplayed = true;
 		}
 		let requestId;
@@ -271,7 +272,7 @@
 		let warningFontFaceDisplayed;
 		window.FontFace = function () {
 			if (!warningFontFaceDisplayed) {
-				console.warn("SingleFile is hooking the FontFace constructor to get font URLs."); // eslint-disable-line no-console
+				warn.call(console, "SingleFile is hooking the FontFace constructor to get font URLs."); // eslint-disable-line no-console
 				warningFontFaceDisplayed = true;
 			}
 			const detail = {};
@@ -305,7 +306,7 @@
 		let warningIntersectionObserverDisplayed;
 		window.IntersectionObserver = function () {
 			if (!warningIntersectionObserverDisplayed) {
-				console.warn("SingleFile is hooking the IntersectionObserver API to detect and load deferred images."); // eslint-disable-line no-console
+				warn.call(console, "SingleFile is hooking the IntersectionObserver API to detect and load deferred images."); // eslint-disable-line no-console
 				warningIntersectionObserverDisplayed = true;
 			}
 			const intersectionObserver = new IntersectionObserver(...arguments);

+ 2 - 1
lib/hooks/content/content-hooks-web.js

@@ -35,12 +35,13 @@
 	const addEventListener = window.addEventListener;
 	const pushState = history.pushState;
 	const console = window.console;
+	const warn = console.warn;
 
 	let warningDisplayed;
 	history.pushState = function (state, title, url) {
 		if (!warningDisplayed) {
 			warningDisplayed = true;
-			console.warn("SingleFile is hooking the history.pushState API to detect navigation."); // eslint-disable-line no-console		
+			warn.call(console, "SingleFile is hooking the history.pushState API to detect navigation."); // eslint-disable-line no-console		
 		}
 		try {
 			dispatchEvent.call(window, new CustomEvent("single-file-push-state", { detail: { state, title, url } }));