Skip to content

Commit de697df

Browse files
authored
Merge pull request #8 from hydrostack/7-hydro-link-issues-in-cshtml-partials
Make sure we take currentTarget and not target in event handlers
2 parents 03cb583 + 73a088e commit de697df

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Scripts/hydro.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,9 @@ document.addEventListener('alpine:init', () => {
498498

499499
clearTimeout(timeout);
500500

501+
const target = event.currentTarget;
501502
timeout = setTimeout(async () => {
502-
await window.Hydro.hydroBind(event.target);
503+
await window.Hydro.hydroBind(target);
503504
}, debounce);
504505
};
505506

@@ -579,15 +580,15 @@ document.addEventListener('alpine:init', () => {
579580
effect(() => {
580581
const handleClick = async (event) => {
581582
event.preventDefault();
582-
const el = event.target;
583-
const url = el.getAttribute('href');
583+
const link = event.currentTarget;
584+
const url = link.getAttribute('href');
584585
currentBoostUrl = url;
585-
const classTimeout = setTimeout(() => el.classList.add('hydro-request'), 200);
586+
const classTimeout = setTimeout(() => link.classList.add('hydro-request'), 200);
586587
try {
587588
await window.Hydro.loadPageContent(url, 'body', true, () => currentBoostUrl === url);
588589
} finally {
589590
clearTimeout(classTimeout);
590-
el.classList.remove('hydro-request')
591+
link.classList.remove('hydro-request')
591592
}
592593
};
593594

0 commit comments

Comments
 (0)