Skip to content

Commit

Permalink
refactor: reuse some variables in plugin (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Sep 23, 2024
1 parent 5bc7a18 commit 15f7438
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions projects/ng-event-plugins/src/plugins/options.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ export class OptionsEventPlugin extends AbstractEventPlugin {
event: string,
handler: EventListener,
): Function {
element.addEventListener(this.unwrap(event), handler, {
const unwrap = this.unwrap(event);
const capture = event.includes('.capture');

element.addEventListener(unwrap, handler, {
capture,
once: event.includes('.once'),
passive: event.includes('.passive'),
capture: event.includes('.capture'),
});

return () =>
element.removeEventListener(
this.unwrap(event),
handler,
event.includes('.capture'),
);
return () => element.removeEventListener(unwrap, handler, {capture});
}
}

0 comments on commit 15f7438

Please sign in to comment.