Browse Source

allow “selector” to be a DOM element in `findAllDOMElements` too

Artur Paikin 7 years ago
parent
commit
981a331c10
1 changed files with 10 additions and 4 deletions
  1. 10 4
      src/core/Utils.js

+ 10 - 4
src/core/Utils.js

@@ -527,12 +527,18 @@ function findDOMElement (element) {
 /**
  * Find one or more DOM elements.
  *
- * @param {string} selector
+ * @param {string} element
  * @return {Array|null}
  */
-function findAllDOMElements (selector) {
-  const elements = [].slice.call(document.querySelectorAll(selector))
-  return elements.length > 0 ? elements : null
+function findAllDOMElements (element) {
+  if (typeof element === 'string') {
+    const elements = [].slice.call(document.querySelectorAll(element))
+    return elements.length > 0 ? elements : null
+  }
+
+  if (typeof element === 'object' && isDOMElement(element)) {
+    return element
+  }
 }
 
 function getSocketHost (url) {