Skip to content

Commit b5084f4

Browse files
authored
Merge pull request #55 from ericglau/45
Fix iframe loading on Firefox
2 parents 4c84fdb + 5f1ea00 commit b5084f4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/routes/+page.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,22 @@
1515
return;
1616
}
1717
18-
const ancestorOrigin = document.location.ancestorOrigins[0];
18+
const referrer = document.referrer; // Available through Wizard. Empty string through Remix.
19+
const ancestorOrigins = document.location.ancestorOrigins; // undefined on Firefox
20+
21+
const parentUrl = ancestorOrigins?.[0] || referrer;
1922
2023
if (dev) {
2124
// add desired behaviour for dev mode.
2225
}
2326
2427
// in case we are developing locally, we want to use the wizard as the parent..
25-
if (ancestorOrigin.includes("wizard") || ancestorOrigin.includes("localhost")) {
28+
if (parentUrl.includes("wizard") || parentUrl.includes("localhost")) {
2629
return parent = 'wizard';
2730
}
2831
29-
if (ancestorOrigin.includes("remix.ethereum")) {
32+
// Remix on Firefox leads to empty parentUrl due to ancestorOrigins and referrer being unavailable.
33+
if (parentUrl.includes("remix.ethereum") || !parentUrl) {
3034
return parent = 'remix';
3135
}
3236

0 commit comments

Comments
 (0)