Skip to content

Commit 127ffce

Browse files
authored
fix: handling of a link to redirect URL (sveltejs#393)
1 parent ebb4380 commit 127ffce

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

content/tutorial/common/src/__client.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ window.addEventListener('focusin', (e) => {
4949
post({ type: 'iframe_took_focus' });
5050
});
5151

52+
let previous_href = location.href;
53+
5254
window.addEventListener('click', (e) => {
5355
let node = e.target;
5456
while (node) {
@@ -60,7 +62,10 @@ window.addEventListener('click', (e) => {
6062
e.preventDefault();
6163
window.open(url, '_blank');
6264
} else {
63-
update_path(url.pathname + url.search + url.hash);
65+
if (location.href !== url.href) {
66+
previous_href = url.href;
67+
update_path(url.pathname + url.search + url.hash);
68+
}
6469
}
6570
}
6671
node = node.parent;
@@ -75,8 +80,6 @@ window.addEventListener('visibilitychange', () => {
7580
}
7681
});
7782

78-
let previous_href = location.href;
79-
8083
const url_observer = new MutationObserver(() => {
8184
if (location.href !== previous_href) {
8285
previous_href = location.href;

0 commit comments

Comments
 (0)