Skip to content

Commit

Permalink
Early type check
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenbo committed Nov 28, 2024
1 parent 397ef3c commit ce1c82a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/incito-browser/incito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -793,20 +793,21 @@ export default class Incito extends MicroEvent<{

start() {
this.el.addEventListener('click', (e) => {
const linkEl = closest(
e.target as HTMLElement,
'.tjek-incito__view [data-link]'
);
if (!(e.target instanceof HTMLElement)) {
return;
}

const linkEl = closest(e.target, '.tjek-incito__view [data-link]');
const carouselEl = closest(
e.target as HTMLElement,
e.target,
'.tjek-incito__carousel-layout-view'
);
const carouselPrevEl = closest(
e.target as HTMLElement,
e.target,
'[data-role=carousel-prev]'
);
const carouselNextEl = closest(
e.target as HTMLElement,
e.target,
'[data-role=carousel-next]'
);
const link = linkEl ? linkEl.dataset.link : null;
Expand Down

0 comments on commit ce1c82a

Please sign in to comment.