Ver código fonte

improve support of lazy loaded contents (e.g. twitter)

Gildas 5 anos atrás
pai
commit
936b14563b

+ 8 - 8
lib/single-file/processors/hooks/content/content-hooks-frames-web.js

@@ -76,11 +76,11 @@
 			element.loading = "eager";
 			element.loading = "eager";
 			element.setAttribute(LAZY_LOAD_ATTRIBUTE, "");
 			element.setAttribute(LAZY_LOAD_ATTRIBUTE, "");
 		});
 		});
+		scrollingElement.__defineGetter__("clientHeight", () => scrollHeight);
+		scrollingElement.__defineGetter__("clientWidth", () => scrollWidth);
+		screen.__defineGetter__("height", () => scrollHeight);
+		screen.__defineGetter__("width", () => scrollWidth);
 		if (!keepZoomLevel) {
 		if (!keepZoomLevel) {
-			scrollingElement.__defineGetter__("clientHeight", () => scrollHeight);
-			scrollingElement.__defineGetter__("clientWidth", () => scrollWidth);
-			screen.__defineGetter__("height", () => scrollHeight);
-			screen.__defineGetter__("width", () => scrollWidth);
 			if (!window._singleFile_getBoundingClientRect) {
 			if (!window._singleFile_getBoundingClientRect) {
 				window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect;
 				window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect;
 				Element.prototype.getBoundingClientRect = function () {
 				Element.prototype.getBoundingClientRect = function () {
@@ -204,11 +204,11 @@
 			element.loading = "lazy";
 			element.loading = "lazy";
 			element.removeAttribute(LAZY_LOAD_ATTRIBUTE);
 			element.removeAttribute(LAZY_LOAD_ATTRIBUTE);
 		});
 		});
+		delete scrollingElement.clientHeight;
+		delete scrollingElement.clientWidth;
+		delete screen.height;
+		delete screen.width;
 		if (!keepZoomLevel) {
 		if (!keepZoomLevel) {
-			delete scrollingElement.clientHeight;
-			delete scrollingElement.clientWidth;
-			delete screen.height;
-			delete screen.width;
 			if (window._singleFile_getBoundingClientRect) {
 			if (window._singleFile_getBoundingClientRect) {
 				Element.prototype.getBoundingClientRect = window._singleFile_getBoundingClientRect;
 				Element.prototype.getBoundingClientRect = window._singleFile_getBoundingClientRect;
 				window.innerHeight = window._singleFile_innerHeight;
 				window.innerHeight = window._singleFile_innerHeight;