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
703 B

5 years ago
  1. 'use strict';
  2. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  3. var domToArray = _interopDefault(require('bianco.dom-to-array'));
  4. /**
  5. * Simple helper to find DOM nodes returning them as array like loopable object
  6. * @param { string|DOMNodeList } selector - either the query or the DOM nodes to arraify
  7. * @param { HTMLElement } ctx - context defining where the query will search for the DOM nodes
  8. * @returns { Array } DOM nodes found as array
  9. */
  10. function $(selector, ctx) {
  11. return domToArray(typeof selector === 'string' ?
  12. (ctx || document).querySelectorAll(selector) :
  13. selector
  14. )
  15. }
  16. module.exports = $;