src/js/dom.js
function dq(selector, context) {
  var nodes = []
  context = context || document
  if (typeof selector === 'function') {
    if (context.attachEvent ? context.readyState === 'complete' : context.readyState !== 'loading') {
      selector()
    } else {
      context.addEventListener('DOMContentLoaded', selector)
    }
  } else if (selector instanceof Element) {
    nodes = [ selector ]
  } else if (typeof selector === 'string') {
    if (selector[0] === '<') {
      nodes = Array.prototype.slice.call(fragment(selector))
    } else {
      nodes = Array.prototype.slice.call(context.querySelectorAll(selector))
    }
  } else {
    nodes = selector
  }
  return new DOMQuery(nodes, context)
}
function dq(selector, context) {
  var nodes = []
  context = context || document
  if (typeof selector === 'function') {
    if (context.attachEvent ? context.readyState === 'complete' : context.readyState !== 'loading') {
      selector()
    } else {
      context.addEventListener('DOMContentLoaded', selector)
    }
  } else if (selector instanceof Element) {
    nodes = [ selector ]
  } else if (typeof selector === 'string') {
    if (selector[0] === '<') {
      nodes = Array.prototype.slice.call(fragment(selector))
    } else {
      nodes = Array.prototype.slice.call(context.querySelectorAll(selector))
    }
  } else {
    nodes = selector
  }
  return new DOMQuery(nodes, context)
}
function dq ( selector , context ) { var nodes = [ ] context = context || document if ( typeof selector === 'function' ) { if ( context . attachEvent ? context . readyState === 'complete' : context . readyState !== 'loading' ) { selector ( ) } else { context . addEventListener ( 'DOMContentLoaded' , selector ) } } else if ( selector instanceof Element ) { nodes = [ selector ] } else if ( typeof selector === 'string' ) { if ( selector [ 0 ] === '<' ) { nodes = Array . prototype . slice . call ( fragment ( selector ) ) } else { nodes = Array . prototype . slice . call ( context . querySelectorAll ( selector ) ) } } else { nodes = selector } return new DOMQuery ( nodes , context ) }
Initialization helper. This method is this module's exported entry point.
@param {string|Array|Element} selector - css selector, one element, array of nodes or html fragment
@param {node} [context=document] - context node in which to query
@returns {DOMQuery} A DOMQuery instance containing the selected set of nodes
Initialization helper . This method is this module s exported entry point .