Skip to content
Snippets Groups Projects
Commit 4f342294 authored by Daniel Kurowski's avatar Daniel Kurowski
Browse files

Fixed empty hash

parent e3c347aa
Branches
Tags
1 merge request!7Improve structure
Pipeline #26912 passed
...@@ -10,6 +10,10 @@ export function initializeOnLinkClickScroll(): void ...@@ -10,6 +10,10 @@ export function initializeOnLinkClickScroll(): void
const element = event.currentTarget as HTMLAnchorElement; const element = event.currentTarget as HTMLAnchorElement;
assert(element !== null); assert(element !== null);
if (element.hash === '' || element.hash === '#') {
return;
}
event.preventDefault(); event.preventDefault();
scrollToTarget(HashTarget.fromString(element.hash, document)); scrollToTarget(HashTarget.fromString(element.hash, document));
}))); })));
......
...@@ -12,11 +12,16 @@ import {assert} from '../assert'; ...@@ -12,11 +12,16 @@ import {assert} from '../assert';
*/ */
export function initializeOnLoadScroll(): void export function initializeOnLoadScroll(): void
{ {
const hash = window.location.hash;
if (hash === '' || hash === '#') {
return;
}
let hashTarget: HashTarget|null = null; let hashTarget: HashTarget|null = null;
const start = performance.now(); const start = performance.now();
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
hashTarget = HashTarget.fromString(window.location.hash, document); hashTarget = HashTarget.fromString(hash, document);
}); });
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment