From f37df727b25a62e8ddf69789c6d8bb82a6c6a931 Mon Sep 17 00:00:00 2001 From: Collins Lagat Date: Tue, 27 Aug 2024 00:43:22 +0300 Subject: [PATCH 1/2] fix: handle cases when elements are in an iframe --- src/core/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/utils.ts b/src/core/utils.ts index 809ad64..1c005e1 100644 --- a/src/core/utils.ts +++ b/src/core/utils.ts @@ -65,8 +65,12 @@ export function elems( ? toArray(wrapper.querySelectorAll(elements)) : elements instanceof HTMLElement ? [elements] + : elements instanceof elements.ownerDocument.defaultView.HTMLElement + ? [elements] : elements instanceof NodeList ? toArray(elements) + : elements instanceof elements.ownerDocument.defaultView.NodeList + ? toArray(elements) : [] } From 28869c38c961333bd2782a31c9701bcb1c05e60e Mon Sep 17 00:00:00 2001 From: Collins Lagat Date: Thu, 29 Aug 2024 22:17:25 +0300 Subject: [PATCH 2/2] refactor: simplify code --- src/core/utils.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/core/utils.ts b/src/core/utils.ts index 1c005e1..0c7457a 100644 --- a/src/core/utils.ts +++ b/src/core/utils.ts @@ -63,15 +63,13 @@ export function elems( ? elements : typeof elements === 'string' ? toArray(wrapper.querySelectorAll(elements)) - : elements instanceof HTMLElement - ? [elements] - : elements instanceof elements.ownerDocument.defaultView.HTMLElement - ? [elements] - : elements instanceof NodeList - ? toArray(elements) - : elements instanceof elements.ownerDocument.defaultView.NodeList - ? toArray(elements) - : [] + : elements instanceof HTMLElement || + elements instanceof elements.ownerDocument.defaultView.HTMLElement + ? [elements] + : elements instanceof NodeList || + elements instanceof elements.ownerDocument.defaultView.NodeList + ? toArray(elements) + : [] } export function prevent(e: any): void {