数通智联化工云平台
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.
 
 
 
 
 

20 lines
469 B

import isDOMElement from './isDOMElement.js'
/**
* Find one or more DOM elements.
*
* @param {string|Node} element
* @returns {Node[]|null}
*/
export default function findAllDOMElements (element) {
if (typeof element === 'string') {
const elements = document.querySelectorAll(element)
return elements.length === 0 ? null : Array.from(elements)
}
if (typeof element === 'object' && isDOMElement(element)) {
return [element]
}
return null
}