Browse Source

support multiple elements in `findDOMElement`

@goto-bus-stop potential danger point. introduced to support multiple
dashboard open triggers #326

Maybe we should always return an array and just use the first element
where multiple elements don’t make sense
Artur Paikin 7 years ago
parent
commit
7dfae9d24c
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/core/Utils.js

+ 6 - 1
src/core/Utils.js

@@ -516,7 +516,12 @@ function isDOMElement (obj) {
  */
 function findDOMElement (element) {
   if (typeof element === 'string') {
-    return document.querySelector(element)
+    const elements = [].slice.call(document.querySelectorAll(element))
+    if (elements.length > 1) {
+      return elements
+    }
+    return elements[0]
+    // return document.querySelector(element)
   }
 
   if (typeof element === 'object' && isDOMElement(element)) {