Skip to content

Commit 4d1e290

Browse files
committed
override: add IntersectionObserver(callback, options) constructor override, which will deproxy options.root if it is set
fixes #136
1 parent eb33b59 commit 4d1e290

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/wombat.js

+26
Original file line numberDiff line numberDiff line change
@@ -4207,6 +4207,29 @@ Wombat.prototype.initBlobOverride = function() {
42074207
this.$wbwindow.Blob.prototype = orig_blob.prototype;
42084208
};
42094209

4210+
Wombat.prototype.initIntersectionObsOverride = function() {
4211+
var orig_iobs = this.$wbwindow.IntersectionObserver;
4212+
4213+
var wombat = this;
4214+
4215+
this.$wbwindow.IntersectionObserver = (function(IObs) {
4216+
return function(callback, options) {
4217+
if (options && options.root) {
4218+
options.root = wombat.proxyToObj(options.root);
4219+
}
4220+
4221+
return new IObs(callback, options);
4222+
};
4223+
4224+
})(this.$wbwindow.IntersectionObserver);
4225+
4226+
this.$wbwindow.IntersectionObserver.prototype = orig_iobs.prototype;
4227+
4228+
Object.defineProperty(this.$wbwindow.IntersectionObserver.prototype, 'constructor', {
4229+
value: this.$wbwindow.IntersectionObserver
4230+
});
4231+
};
4232+
42104233
Wombat.prototype.initWSOverride = function() {
42114234
if (!this.$wbwindow.WebSocket || !this.$wbwindow.WebSocket.prototype) {
42124235
return;
@@ -6668,6 +6691,9 @@ Wombat.prototype.wombatInit = function() {
66686691
this.overrideIframeContentAccess('contentWindow');
66696692
this.overrideIframeContentAccess('contentDocument');
66706693

6694+
// IntersectionObserver constructor override
6695+
this.initIntersectionObsOverride();
6696+
66716697
// override funcs to convert first arg proxy->obj
66726698
this.overrideFuncArgProxyToObj(this.$wbwindow.MutationObserver, 'observe');
66736699
this.overrideFuncArgProxyToObj(

0 commit comments

Comments
 (0)