Skip to content

Commit e8a9f91

Browse files
authored
fix(widget): call onReady against iframe (#7436)
1 parent da03d34 commit e8a9f91

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

libs/widget-lib/src/cowSwapWidget.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ export function createCowSwapWidget(container: HTMLElement, props: CowSwapWidget
6969
logWidget('Resolved trusted iframe origin', { iframeOrigin })
7070
const windowListeners: WindowListener[] = []
7171

72-
if (onReady) {
73-
windowListeners.push(listenToReady(iframe.contentWindow || window, iframeOrigin, onReady))
74-
}
75-
7672
// 2. Clear the content (delete any previous iFrame if it exists)
7773
container.innerHTML = ''
7874
container.appendChild(iframe)
@@ -83,6 +79,10 @@ export function createCowSwapWidget(container: HTMLElement, props: CowSwapWidget
8379
throw new Error('Iframe does not contain a window!')
8480
}
8581

82+
if (onReady) {
83+
windowListeners.push(listenToReady(iframeWindow, iframeOrigin, onReady))
84+
}
85+
8686
// 3. Send appCode (once the widget posts the ACTIVATE message)
8787
windowListeners.push(sendAppCodeOnActivation(iframeWindow, iframeOrigin, params.appCode))
8888

0 commit comments

Comments
 (0)