MCPcopy
hub / github.com/QwikDev/partytown / insertIframe

Function insertIframe

src/lib/web-worker/worker-exec.ts:182–214  ·  view source on GitHub ↗
(winId: WinId, iframe: WorkerInstance)

Source from the content-addressed store, hash-verified

180};
181
182export const insertIframe = (winId: WinId, iframe: WorkerInstance) => {
183 // an iframe element's instanceId is also
184 // the winId of its contentWindow
185 let i = 0;
186 let type: string;
187 let handlers: EventHandler[];
188
189 let callback = () => {
190 if (
191 environments[winId] &&
192 environments[winId].$isInitialized$ &&
193 !environments[winId].$isLoading$
194 ) {
195 type = getInstanceStateValue<StateProp>(iframe, StateProp.loadErrorStatus)
196 ? StateProp.errorHandlers
197 : StateProp.loadHandlers;
198
199 handlers = getInstanceStateValue<EventHandler[]>(iframe, type);
200 if (handlers) {
201 handlers.map((handler) => handler({ type }));
202 }
203 } else if (i++ > 2000) {
204 handlers = getInstanceStateValue<EventHandler[]>(iframe, StateProp.errorHandlers);
205 if (handlers) {
206 handlers.map((handler) => handler({ type: StateProp.errorHandlers }));
207 }
208 } else {
209 setTimeout(callback, 9);
210 }
211 };
212
213 callback();
214};
215
216const resolveBaseLocation = (env: WebWorkerEnvironment, baseLocation?: Location) => {
217 baseLocation = env.$location$;

Callers 1

insertBeforeMethod · 0.90

Calls 1

callbackFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…