Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: init waits for the iframe to be loaded #236

Merged
merged 4 commits into from
Jul 29, 2024
Merged

Conversation

mikesposito
Copy link
Member

@mikesposito mikesposito commented Jul 24, 2024

Currently, updateTransportMethod stores a promise in a class variable that will resolve only when the iframe is loaded. Though, there are instances when this mechanism is broken - like when updateTransportMethod is called multiple times.

This PR changes the init method to wait for the iframe to be fully loaded before resolving. This implies that when updateTransportMethod is called, the bridge needs to be already initialized (with init), or an error is thrown

Fixes #70

@mikesposito mikesposito requested a review from a team as a code owner July 24, 2024 10:47
@mikesposito mikesposito changed the title fix: await for iframe load on init fix: init waits for the iframe to be loaded Jul 24, 2024
Comment on lines +4 to +7
const shim = {
head: {
appendChild: (child: { onload?: () => void }) => {
child.onload?.();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentShim.head.appendChild seems to be the best place to forge the iframe onload. I removed some code from tests that was intended to do this

@mikesposito mikesposito requested a review from Gudahtt July 25, 2024 11:58
@mikesposito mikesposito requested a review from ccharly July 25, 2024 12:22
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mikesposito mikesposito merged commit 1ef5ab9 into main Jul 29, 2024
19 checks passed
@mikesposito mikesposito deleted the fix/await-iframe-init branch July 29, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

updateTransportMethod doesn't resolve when called multiple times successively before iframe loads
2 participants