@@ -262,22 +262,12 @@ export class IframeSandbox implements SignalSandbox {
262262 this . iframe . style . display = 'none'
263263 this . iframe . src = 'about:blank'
264264 document . body . appendChild ( this . iframe )
265- this . iframeReady = this . listenForIframeInit ( )
266265
267266 const doc = this . iframe . contentDocument !
268267 doc . open ( )
269268 doc . write ( this . getIframeHTML ( processSignalFn ) )
270269 doc . close ( )
271-
272- const runtimeJs = this . getIframeJS ( processSignalFn )
273- const blob = new Blob ( [ runtimeJs ] , { type : 'application/javascript' } )
274- const runtimeScript = doc . createElement ( 'script' )
275- runtimeScript . src = URL . createObjectURL ( blob )
276- doc . head . appendChild ( runtimeScript )
277- }
278-
279- private listenForIframeInit ( ) : Promise < void > {
280- return new Promise ( ( resolve ) => {
270+ this . iframeReady = new Promise ( ( resolve ) => {
281271 window . addEventListener ( 'message' , ( e ) => {
282272 if (
283273 e . source === this . iframe . contentWindow &&
@@ -290,6 +280,11 @@ export class IframeSandbox implements SignalSandbox {
290280 }
291281 } )
292282 } )
283+ const runtimeJs = this . getIframeJS ( processSignalFn )
284+ const blob = new Blob ( [ runtimeJs ] , { type : 'application/javascript' } )
285+ const runtimeScript = doc . createElement ( 'script' )
286+ runtimeScript . src = URL . createObjectURL ( blob )
287+ doc . head . appendChild ( runtimeScript )
293288 }
294289
295290 private getIframeHTML ( processSignalFn ?: string ) : string {
0 commit comments