From 15f74383cb48abbaa047e7bf46cf9630831445f7 Mon Sep 17 00:00:00 2001 From: Maksim Ivanov Date: Mon, 23 Sep 2024 10:07:31 +0300 Subject: [PATCH] refactor: reuse some variables in plugin (#542) --- .../ng-event-plugins/src/plugins/options.plugin.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/projects/ng-event-plugins/src/plugins/options.plugin.ts b/projects/ng-event-plugins/src/plugins/options.plugin.ts index 7402580..87588df 100644 --- a/projects/ng-event-plugins/src/plugins/options.plugin.ts +++ b/projects/ng-event-plugins/src/plugins/options.plugin.ts @@ -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}); } }