Skip to content

Commit

Permalink
fix: undefined listener invokes (bug atomiks#1027) (atomiks#1028)
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyCompiler authored Feb 5, 2022
1 parent 21a9c84 commit ad85f6f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/dom-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,17 @@ export function updateTransitionEndListener(
action: 'add' | 'remove',
listener: (event: TransitionEvent) => void
): void {
const method = `${action}EventListener` as
| 'addEventListener'
| 'removeEventListener';

// some browsers apparently support `transition` (unprefixed) but only fire
// `webkitTransitionEnd`...
['transitionend', 'webkitTransitionEnd'].forEach((event) => {
box[method](event, listener as EventListener);
});
if (listener) {
const method = `${action}EventListener` as
| 'addEventListener'
| 'removeEventListener';

// some browsers apparently support `transition` (unprefixed) but only fire
// `webkitTransitionEnd`...
['transitionend', 'webkitTransitionEnd'].forEach((event) => {
box[method](event, listener as EventListener);
});
}
}

/**
Expand Down

0 comments on commit ad85f6f

Please sign in to comment.