Skip to content

Commit

Permalink
override: add IntersectionObserver(callback, options) constructor ove…
Browse files Browse the repository at this point in the history
…rride, which will deproxy options.root if it is set

fixes #136
  • Loading branch information
ikreymer committed Feb 22, 2024
1 parent eb33b59 commit 4d1e290
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/wombat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4207,6 +4207,29 @@ Wombat.prototype.initBlobOverride = function() {
this.$wbwindow.Blob.prototype = orig_blob.prototype;
};

Wombat.prototype.initIntersectionObsOverride = function() {
var orig_iobs = this.$wbwindow.IntersectionObserver;

var wombat = this;

this.$wbwindow.IntersectionObserver = (function(IObs) {
return function(callback, options) {
if (options && options.root) {
options.root = wombat.proxyToObj(options.root);
}

return new IObs(callback, options);
};

})(this.$wbwindow.IntersectionObserver);

this.$wbwindow.IntersectionObserver.prototype = orig_iobs.prototype;

Object.defineProperty(this.$wbwindow.IntersectionObserver.prototype, 'constructor', {
value: this.$wbwindow.IntersectionObserver
});
};

Wombat.prototype.initWSOverride = function() {
if (!this.$wbwindow.WebSocket || !this.$wbwindow.WebSocket.prototype) {
return;
Expand Down Expand Up @@ -6668,6 +6691,9 @@ Wombat.prototype.wombatInit = function() {
this.overrideIframeContentAccess('contentWindow');
this.overrideIframeContentAccess('contentDocument');

// IntersectionObserver constructor override
this.initIntersectionObsOverride();

// override funcs to convert first arg proxy->obj
this.overrideFuncArgProxyToObj(this.$wbwindow.MutationObserver, 'observe');
this.overrideFuncArgProxyToObj(
Expand Down

0 comments on commit 4d1e290

Please sign in to comment.