Fix firefox errors in cross-iframe communiccation

This commit is contained in:
Tamius Han 2026-04-03 13:26:01 +02:00
parent ef5ba706b7
commit 3f032619b4

View File

@ -90,7 +90,24 @@ export default class EventBus {
}
}
private cloneContext(context: EventBusContext = {}): EventBusContext {
return {
stopPropagation: context.stopPropagation,
origin: context.origin,
frameUrl: context.frameUrl,
visitedBusses: context.visitedBusses ? [...context.visitedBusses] : undefined,
commandId: context.commandId,
comms: context.comms ? {
forwardTo: context.comms.forwardTo,
sourceFrame: context.comms.sourceFrame ? { ...context.comms.sourceFrame } : undefined
} : undefined,
borderCrossings: context.borderCrossings ? { ...context.borderCrossings } : undefined
};
}
send(command: string, commandData: any, context: EventBusContext = {}) {
context = this.cloneContext(context); // Firefox throws an error if we don't clone the context.
if (context.visitedBusses?.includes(this.uuid)) {
console.warn('this bus was already visited before. Doing nothing.');
return;