Skip to content

Commit 2446fd0

Browse files
committed
fix: Continuous navigation sync in preview
1 parent 74d8a40 commit 2446fd0

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

panel/src/components/Views/Preview/PreviewBrowser.vue

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ export default {
6464
},
6565
emits: ["discard", "navigate", "open", "pin", "submit"],
6666
computed: {
67-
document() {
68-
return this.$refs.browser.contentDocument;
69-
},
7067
window() {
7168
return this.$refs.browser.contentWindow;
7269
}
@@ -107,24 +104,26 @@ export default {
107104
}
108105
},
109106
onLoad() {
107+
const document = this.$refs.browser.contentDocument;
108+
110109
// if the browser got redirected during load
111110
// navigate to the proper preview URL for this new URL
112111
// (but only if the new URL doesn't already contain _version and _token)
113-
if (this.src !== this.document.URL) {
114-
const url = new URL(this.document.URL);
112+
if (this.src !== document.URL) {
113+
const url = new URL(document.URL);
115114
116115
if (
117116
url.searchParams.has("_token") === false ||
118117
url.searchParams.has("_version") === false
119118
) {
120-
this.$emit("navigate", { browser: url });
119+
return this.$emit("navigate", { browser: url });
121120
}
122121
}
123122
124123
// attach event listeners to all links inside the iframe
125-
this.document.addEventListener("click", this.onClick);
124+
document.addEventListener("click", this.onClick);
126125
127-
for (const link of this.document.querySelectorAll("a")) {
126+
for (const link of document.querySelectorAll("a")) {
128127
link.addEventListener("click", this.onClick);
129128
}
130129
},

0 commit comments

Comments
 (0)