refactor: automatic proxy constructor

This commit is contained in:
velzie 2024-07-19 13:52:34 -04:00
parent eba3e759fd
commit 80d51ed7a7
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
11 changed files with 192 additions and 131 deletions

View file

@ -127,18 +127,21 @@ Object.defineProperty(Element.prototype, "innerHTML", {
},
});
MutationObserver.prototype.observe = new Proxy(MutationObserver.prototype.observe, {
apply(target, thisArg, argArray) {
if (argArray[0] === documentProxy) argArray[0] = document;
MutationObserver.prototype.observe = new Proxy(
MutationObserver.prototype.observe,
{
apply(target, thisArg, argArray) {
if (argArray[0] === documentProxy) argArray[0] = document;
return Reflect.apply(target, thisArg, argArray);
return Reflect.apply(target, thisArg, argArray);
},
}
});
);
document.createTreeWalker = new Proxy(document.createTreeWalker, {
apply(target, thisArg, argArray) {
if (argArray[0] === documentProxy) argArray[0] = document;
return Reflect.apply(target, thisArg, argArray);
}
},
});