MCPcopy
hub / github.com/bendc/sprint / Init

Function Init

sprint.js:607–640  ·  view source on GitHub ↗
(selector, context)

Source from the content-addressed store, hash-verified

605 // constructor
606
607 var Init = function(selector, context) {
608 if (typeof selector == "string") {
609 // create DOM element
610 if (selector[0] == "<") {
611 this.dom = [createDOM(selector)]
612 }
613 // select DOM elements
614 else {
615 this.dom = context && context instanceof Init
616 ? context.find(selector).get()
617 : selectElements(selector, context)
618 }
619 }
620 else if (Array.isArray(selector)) {
621 this.dom = sanitize(selector)
622 }
623 else if (
624 selector instanceof NodeList ||
625 selector instanceof HTMLCollection
626 ) {
627 this.dom = toArray(selector)
628 }
629 else if (selector instanceof Init) {
630 return selector
631 }
632 else if (typeof selector == "function") {
633 return this.ready(selector)
634 }
635 else {
636 // assume DOM node
637 this.dom = selector ? [selector] : []
638 }
639 this.length = this.dom.length
640 }
641
642 Init.prototype = {
643 add: function(selector) {

Callers

nothing calls this directly

Calls 4

createDOMFunction · 0.85
selectElementsFunction · 0.85
sanitizeFunction · 0.85
toArrayFunction · 0.85

Tested by

no test coverage detected