Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@uppy/utils: fix findAllDOMElements type #4997

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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