Skip to content

Commit 9aa5e28

Browse files
authored
fix: refresh URL (sveltejs#319)
1 parent 3c6a656 commit 9aa5e28

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

content/tutorial/common/src/__client.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ function ping() {
105105
);
106106
}
107107

108+
let pre_url = location.href;
109+
const url_observer = new MutationObserver(() => {
110+
if (location.href !== pre_url) {
111+
pre_url = location.href;
112+
ping();
113+
}
114+
});
115+
url_observer.observe(document, { subtree: true, childList: true, attributes: true });
116+
108117
ping();
109118

110119
if (import.meta.hot) {

src/routes/tutorial/[slug]/Output.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
if (paused) return;
4242
4343
if (e.data.type === 'ping') {
44+
path = e.data.data.path ?? path;
4445
loading = false;
4546
} else if (e.data.type === 'warnings') {
4647
warnings.update(($warnings) => ({

0 commit comments

Comments
 (0)