all files / src/ index.js

100% Statements 14/14
100% Branches 1/1
100% Functions 2/2
100% Lines 14/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                      69×                   45× 153×               58×    
import * as DOMClass from './class'
 
import * as collection from './collection'
import * as classActions from './class'
import * as styles from './styles'
import * as events from './events'
import * as nodes from './nodes'
import {uuid} from './helper'
import {query} from './query'
 
function init (selector, context = document) {
  this.query(selector, context)
}
 
const $ = {
  // 全局唯一
  uuid,
 
  init,
  query,
  // 扩展
  extend (obj) {
    for (let key in obj) {
      $[key] = obj[key]
    }
  }
}
 
$.init.prototype = $
 
$.extend(collection)
$.extend(classActions)
$.extend(styles)
$.extend(events)
$.extend(nodes)
 
export default function simpleDomQuery (selector) {
  return new $.init(selector)
}
simpleDomQuery.uuid = uuid
simpleDomQuery.simpleDomQuery = $
 
window.$ = simpleDomQuery