fix: do event proxying on workers

This commit is contained in:
Percs 2024-10-12 03:11:44 -05:00
parent 18f85c7860
commit b15633fe8b

View file

@ -141,13 +141,8 @@ export default function (client: ScramjetClient, self: Self) {
}, },
}); });
if (!iswindow) return; const targets = [self.self, self.MessagePort.prototype] as Array<any>;
if (iswindow) targets.push(self.HTMLElement.prototype);
const targets = [
self.window,
self.HTMLElement.prototype,
self.MessagePort.prototype,
];
if (self.Worker) targets.push(self.Worker.prototype); if (self.Worker) targets.push(self.Worker.prototype);
for (const target of targets) { for (const target of targets) {
@ -159,6 +154,7 @@ export default function (client: ScramjetClient, self: Self) {
key.startsWith("on") && key.startsWith("on") &&
handlers[key.slice(2)] handlers[key.slice(2)]
) { ) {
console.log(key);
const descriptor = nativeGetOwnPropertyDescriptor(target, key); const descriptor = nativeGetOwnPropertyDescriptor(target, key);
if (!descriptor.get || !descriptor.set || !descriptor.configurable) if (!descriptor.get || !descriptor.set || !descriptor.configurable)
continue; continue;