Skip to content

Commit

Permalink
@uppy/utils: fix findAllDOMElements type (#4997)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored Mar 14, 2024
1 parent 53e6046 commit da623ff
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/@uppy/utils/src/findAllDOMElements.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import isDOMElement from './isDOMElement.ts'

function findAllDOMElements<T>(
element: T,
context?: ParentNode,
): T extends Element ? [T]
: T extends Node | string ? Element[] | null
: null

/**
* Find one or more DOM elements.
*/
export default function findAllDOMElements(
element: string | Node,
): Node[] | null {
function findAllDOMElements(element: unknown): Node[] | null {
if (typeof element === 'string') {
const elements = document.querySelectorAll(element)
return elements.length === 0 ? null : Array.from(elements)
Expand All @@ -17,3 +22,5 @@ export default function findAllDOMElements(

return null
}

export default findAllDOMElements

0 comments on commit da623ff

Please sign in to comment.