|
|
@@ -60,7 +60,7 @@
|
|
|
const observedElements = new Map();
|
|
|
let loadDeferredImages;
|
|
|
|
|
|
- addEventListener(LOAD_DEFERRED_IMAGES_START_EVENT, () => {
|
|
|
+ addEventListener.call(window, LOAD_DEFERRED_IMAGES_START_EVENT, () => {
|
|
|
loadDeferredImages = true;
|
|
|
const scrollingElement = document.scrollingElement || document.documentElement;
|
|
|
const clientHeight = scrollingElement.clientHeight;
|
|
|
@@ -97,20 +97,20 @@
|
|
|
const result = new Image(...arguments);
|
|
|
result.__defineSetter__("src", function (value) {
|
|
|
image.src = value;
|
|
|
- dispatchEvent(new CustomEvent(LOAD_IMAGE_EVENT, { detail: image.src }));
|
|
|
+ dispatchEvent.call(window, new CustomEvent(LOAD_IMAGE_EVENT, { detail: image.src }));
|
|
|
});
|
|
|
result.__defineGetter__("src", function () {
|
|
|
return image.src;
|
|
|
});
|
|
|
result.__defineSetter__("srcset", function (value) {
|
|
|
- dispatchEvent(new CustomEvent(LOAD_IMAGE_EVENT));
|
|
|
+ dispatchEvent.call(window, new CustomEvent(LOAD_IMAGE_EVENT));
|
|
|
image.srcset = value;
|
|
|
});
|
|
|
result.__defineGetter__("srcset", function () {
|
|
|
return image.srcset;
|
|
|
});
|
|
|
image.onload = image.onloadend = image.onerror = event => {
|
|
|
- dispatchEvent(new CustomEvent(IMAGE_LOADED_EVENT, { detail: image.src }));
|
|
|
+ dispatchEvent.call(window, new CustomEvent(IMAGE_LOADED_EVENT, { detail: image.src }));
|
|
|
result.dispatchEvent(new UIEvent(event.type, event));
|
|
|
};
|
|
|
if (image.decode) {
|
|
|
@@ -130,13 +130,13 @@
|
|
|
const transformOriginPriority = document.documentElement.style.getPropertyPriority("transform-origin");
|
|
|
document.documentElement.style.setProperty("transform-origin", (zoomFactorX < 1 ? "50%" : "0") + " " + (zoomFactorY < 1 ? "50%" : "0") + " 0", "important");
|
|
|
document.documentElement.style.setProperty("transform", "scale3d(" + zoomFactor + ", " + zoomFactor + ", 1)", "important");
|
|
|
- dispatchEvent(new UIEvent("resize"));
|
|
|
- dispatchEvent(new UIEvent("scroll"));
|
|
|
+ dispatchEvent.call(window, new UIEvent("resize"));
|
|
|
+ dispatchEvent.call(window, new UIEvent("scroll"));
|
|
|
document.documentElement.style.setProperty("transform", transform, transformPriority);
|
|
|
document.documentElement.style.setProperty("transform-origin", transformOrigin, transformOriginPriority);
|
|
|
}
|
|
|
- dispatchEvent(new UIEvent("resize"));
|
|
|
- dispatchEvent(new UIEvent("scroll"));
|
|
|
+ dispatchEvent.call(window, new UIEvent("resize"));
|
|
|
+ dispatchEvent.call(window, new UIEvent("scroll"));
|
|
|
const docBoundingRect = scrollingElement.getBoundingClientRect();
|
|
|
Array.from(observers, ([intersectionObserver, observer]) => {
|
|
|
const rootBoundingRect = observer.options && observer.options.root && observer.options.root.getBoundingClientRect();
|
|
|
@@ -161,7 +161,7 @@
|
|
|
});
|
|
|
|
|
|
|
|
|
- addEventListener(LOAD_DEFERRED_IMAGES_END_EVENT, () => {
|
|
|
+ addEventListener.call(window, LOAD_DEFERRED_IMAGES_END_EVENT, () => {
|
|
|
const scrollingElement = document.scrollingElement || document.documentElement;
|
|
|
delete scrollingElement.clientHeight;
|
|
|
delete scrollingElement.clientWidth;
|
|
|
@@ -181,11 +181,11 @@
|
|
|
delete window._singleFileImage;
|
|
|
}
|
|
|
loadDeferredImages = false;
|
|
|
- dispatchEvent(new UIEvent("resize"));
|
|
|
- dispatchEvent(new UIEvent("scroll"));
|
|
|
+ dispatchEvent.call(window, new UIEvent("resize"));
|
|
|
+ dispatchEvent.call(window, new UIEvent("scroll"));
|
|
|
});
|
|
|
|
|
|
- addEventListener(BLOCK_COOKIES_START_EVENT, () => {
|
|
|
+ addEventListener.call(window, BLOCK_COOKIES_START_EVENT, () => {
|
|
|
try {
|
|
|
document.__defineGetter__("cookie", () => { throw new Error("document.cookie temporary blocked by SingleFile"); });
|
|
|
} catch (error) {
|
|
|
@@ -193,11 +193,11 @@
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- addEventListener(BLOCK_COOKIES_END_EVENT, () => {
|
|
|
+ addEventListener.call(window, BLOCK_COOKIES_END_EVENT, () => {
|
|
|
delete document.cookie;
|
|
|
});
|
|
|
|
|
|
- addEventListener(BLOCK_STORAGE_START_EVENT, () => {
|
|
|
+ addEventListener.call(window, BLOCK_STORAGE_START_EVENT, () => {
|
|
|
if (!window._singleFile_localStorage) {
|
|
|
window._singleFile_localStorage = window.localStorage;
|
|
|
window.__defineGetter__("localStorage", () => { throw new Error("localStorage temporary blocked by SingleFile"); });
|
|
|
@@ -208,7 +208,7 @@
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- addEventListener(BLOCK_STORAGE_END_EVENT, () => {
|
|
|
+ addEventListener.call(window, BLOCK_STORAGE_END_EVENT, () => {
|
|
|
if (window._singleFile_localStorage) {
|
|
|
delete window.localStorage;
|
|
|
window.localStorage = window._singleFile_localStorage;
|
|
|
@@ -289,10 +289,10 @@
|
|
|
reader.readAsDataURL(new Blob([detail.src]));
|
|
|
reader.addEventListener("load", () => {
|
|
|
detail.src = "url(" + reader.result + ")";
|
|
|
- dispatchEvent(new CustomEvent(NEW_FONT_FACE_EVENT, { detail }));
|
|
|
+ dispatchEvent.call(window, new CustomEvent(NEW_FONT_FACE_EVENT, { detail }));
|
|
|
});
|
|
|
} else {
|
|
|
- dispatchEvent(new CustomEvent(NEW_FONT_FACE_EVENT, { detail }));
|
|
|
+ dispatchEvent.call(window, new CustomEvent(NEW_FONT_FACE_EVENT, { detail }));
|
|
|
}
|
|
|
return new FontFace(...arguments);
|
|
|
};
|