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

Fixed empty hash

parent e3c347aa
No related branches found
No related tags found
1 merge request!7Improve structure
Pipeline #26912 passed
......@@ -10,6 +10,10 @@ export function initializeOnLinkClickScroll(): void
const element = event.currentTarget as HTMLAnchorElement;
assert(element !== null);
if (element.hash === '' || element.hash === '#') {
return;
}
event.preventDefault();
scrollToTarget(HashTarget.fromString(element.hash, document));
})));
......
......@@ -12,11 +12,16 @@ import {assert} from '../assert';
*/
export function initializeOnLoadScroll(): void
{
const hash = window.location.hash;
if (hash === '' || hash === '#') {
return;
}
let hashTarget: HashTarget|null = null;
const start = performance.now();
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.
Finish editing this message first!
Please register or to comment