|
|
@@ -244,18 +244,18 @@ this.hooksFrame = this.hooksFrame || (() => {
|
|
|
};
|
|
|
window.cancelAnimationFrame.toString = function () { return "cancelAnimationFrame() { [native code] }"; };
|
|
|
|
|
|
- const FontFace = window.FontFace;
|
|
|
- let warningFontFaceDisplayed;
|
|
|
- window.__defineGetter__("FontFace", () => new Proxy(FontFace, {
|
|
|
- construct(FontFace, argumentsList) {
|
|
|
+ if (window.FontFace) {
|
|
|
+ const FontFace = window.FontFace;
|
|
|
+ let warningFontFaceDisplayed;
|
|
|
+ window.FontFace = function () {
|
|
|
if (!warningFontFaceDisplayed) {
|
|
|
console.warn("SingleFile is hooking the FontFace constructor to get font URLs."); // eslint-disable-line no-console
|
|
|
warningFontFaceDisplayed = true;
|
|
|
}
|
|
|
const detail = {};
|
|
|
- detail["font-family"] = argumentsList[0];
|
|
|
- detail.src = argumentsList[1];
|
|
|
- const descriptors = argumentsList[2];
|
|
|
+ detail["font-family"] = arguments[0];
|
|
|
+ detail.src = arguments[1];
|
|
|
+ const descriptors = arguments[2];
|
|
|
if (descriptors) {
|
|
|
Object.keys(descriptors).forEach(descriptor => {
|
|
|
if (FONT_STYLE_PROPERTIES[descriptor]) {
|
|
|
@@ -273,50 +273,47 @@ this.hooksFrame = this.hooksFrame || (() => {
|
|
|
} else {
|
|
|
dispatchEvent(new CustomEvent(NEW_FONT_FACE_EVENT, { detail }));
|
|
|
}
|
|
|
- return new FontFace(...argumentsList);
|
|
|
- }
|
|
|
- }));
|
|
|
+ return new FontFace(...arguments);
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
if (window.IntersectionObserver) {
|
|
|
const IntersectionObserver = window.IntersectionObserver;
|
|
|
const observeIntersection = IntersectionObserver.prototype.observe;
|
|
|
const unobserveIntersection = IntersectionObserver.prototype.unobserve;
|
|
|
let warningIntersectionObserverDisplayed;
|
|
|
- window.__defineGetter__("IntersectionObserver", () => new Proxy(IntersectionObserver, {
|
|
|
- construct(IntersectionObserver, argumentsList) {
|
|
|
- if (!warningIntersectionObserverDisplayed) {
|
|
|
- console.warn("SingleFile is hooking the IntersectionObserver API to detect and load deferred images."); // eslint-disable-line no-console
|
|
|
- warningRequestAnimationFrameDisplayed = true;
|
|
|
+ window.IntersectionObserver = function () {
|
|
|
+ if (!warningIntersectionObserverDisplayed) {
|
|
|
+ console.warn("SingleFile is hooking the IntersectionObserver API to detect and load deferred images."); // eslint-disable-line no-console
|
|
|
+ warningRequestAnimationFrameDisplayed = true;
|
|
|
+ }
|
|
|
+ const intersectionObserver = new IntersectionObserver(...arguments);
|
|
|
+ const callback = arguments[0];
|
|
|
+ const options = arguments[1];
|
|
|
+ intersectionObserver.observe = function (targetElement) {
|
|
|
+ let targetElements = observedElements.get(intersectionObserver);
|
|
|
+ if (!targetElements) {
|
|
|
+ targetElements = [];
|
|
|
+ observedElements.set(intersectionObserver, targetElements);
|
|
|
}
|
|
|
- const intersectionObserver = new IntersectionObserver(...argumentsList);
|
|
|
- const callback = argumentsList[0];
|
|
|
- const options = argumentsList[1];
|
|
|
- intersectionObserver.observe = function (targetElement) {
|
|
|
- let targetElements = observedElements.get(intersectionObserver);
|
|
|
- if (!targetElements) {
|
|
|
- targetElements = [];
|
|
|
+ targetElements.push(targetElement);
|
|
|
+ return observeIntersection.call(intersectionObserver, targetElement);
|
|
|
+ };
|
|
|
+ intersectionObserver.unobserve = function (targetElement) {
|
|
|
+ let targetElements = observedElements.get(intersectionObserver);
|
|
|
+ if (targetElements) {
|
|
|
+ targetElements = targetElements.filter(element => element <= targetElement);
|
|
|
+ if (targetElements.length) {
|
|
|
observedElements.set(intersectionObserver, targetElements);
|
|
|
+ } else {
|
|
|
+ observedElements.delete(intersectionObserver);
|
|
|
}
|
|
|
- targetElements.push(targetElement);
|
|
|
- return observeIntersection.call(intersectionObserver, targetElement);
|
|
|
- };
|
|
|
- intersectionObserver.unobserve = function (targetElement) {
|
|
|
- let targetElements = observedElements.get(intersectionObserver);
|
|
|
- if (targetElements) {
|
|
|
- targetElements = targetElements.filter(element => element <= targetElement);
|
|
|
- if (targetElements.length) {
|
|
|
- observedElements.set(intersectionObserver, targetElements);
|
|
|
- } else {
|
|
|
- observedElements.delete(intersectionObserver);
|
|
|
- }
|
|
|
- }
|
|
|
- return unobserveIntersection.call(intersectionObserver, targetElement);
|
|
|
- };
|
|
|
- observers.set(intersectionObserver, { callback, options });
|
|
|
- return intersectionObserver;
|
|
|
- }
|
|
|
- }));
|
|
|
- window.__defineSetter__("IntersectionObserver", () => { });
|
|
|
+ }
|
|
|
+ return unobserveIntersection.call(intersectionObserver, targetElement);
|
|
|
+ };
|
|
|
+ observers.set(intersectionObserver, { callback, options });
|
|
|
+ return intersectionObserver;
|
|
|
+ };
|
|
|
}
|
|
|
}
|
|
|
|