Skip to content

Commit

Permalink
one-event: Accept array of selectors
Browse files Browse the repository at this point in the history
Followup to #53
  • Loading branch information
fregante committed Aug 20, 2024
1 parent 99ea1f0 commit 4157b53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions one-event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ test('should resolve with `undefined` if the signal has already aborted', async
const event = await promise;
expect(event).toBeUndefined();
});

test('should accept an array of selectors', async t => {
const promise = oneEvent(['a', 'b'], 'click');
anchor.click();
const event = await promise;
expect(event).toBeInstanceOf(MouseEvent);
});
6 changes: 3 additions & 3 deletions one-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function oneEvent<
TElement extends Element = ParseSelector<Selector, HTMLElement>,
TEventType extends EventType = EventType,
>(
selector: Selector,
selector: Selector | Selector[],
type: TEventType,
options?: DelegateOptions
): Promise<DelegateEvent<GlobalEventHandlersEventMap[TEventType], TElement>>;
Expand All @@ -22,7 +22,7 @@ async function oneEvent<
TElement extends Element = HTMLElement,
TEventType extends EventType = EventType,
>(
selector: string,
selector: string | string[],
type: TEventType,
options?: DelegateOptions
): Promise<DelegateEvent<GlobalEventHandlersEventMap[TEventType], TElement>>;
Expand All @@ -32,7 +32,7 @@ async function oneEvent<
TElement extends Element,
TEventType extends EventType = EventType,
>(
selector: string,
selector: string | string[],
type: TEventType,
options: DelegateOptions = {},
): Promise<DelegateEvent<GlobalEventHandlersEventMap[TEventType], TElement> | undefined> {
Expand Down

0 comments on commit 4157b53

Please sign in to comment.