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.

14 lines
545 B

5 years ago
  1. import domToArray from 'bianco.dom-to-array'
  2. /**
  3. * Simple helper to find DOM nodes returning them as array like loopable object
  4. * @param { string|DOMNodeList } selector - either the query or the DOM nodes to arraify
  5. * @param { HTMLElement } ctx - context defining where the query will search for the DOM nodes
  6. * @returns { Array } DOM nodes found as array
  7. */
  8. export default function $(selector, ctx) {
  9. return domToArray(typeof selector === 'string' ?
  10. (ctx || document).querySelectorAll(selector) :
  11. selector
  12. )
  13. }