You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
362 B
19 lines
362 B
import isDOMElement from './isDOMElement.js'
|
|
|
|
/**
|
|
* Find a DOM element.
|
|
*
|
|
* @param {Node|string} element
|
|
* @returns {Node|null}
|
|
*/
|
|
export default function findDOMElement (element, context = document) {
|
|
if (typeof element === 'string') {
|
|
return context.querySelector(element)
|
|
}
|
|
|
|
if (isDOMElement(element)) {
|
|
return element
|
|
}
|
|
|
|
return null
|
|
}
|
|
|