Zepto source notes (a)

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Recent research on the Zepto source code, this is the first report analysis, welcome to continue to pay attention to, the first written source notes, hope everyone pointing pointing, first article for the first time and cause analysis is not too dry cargo, hopes the following articles can become you greatly in the eyes of the dry cargo.


Zepto is the operating results of an anonymous function, while zepto is a definition of the object of the anonymous function, pay attention to the distinction between


 zepto.matches 

match = ~zepto.qsa(parent, selector).indexOf(element)

zepto.qsa: Zepto optimized selector

zepto.qsa(parent, selector).indexOf(element): If the selector returns element cannot find value in the statement run value is -1

~zepto.qsa(parent, selector).indexOf(element)  :On the back of the value of the counter, operator precedence"."


function type(obj)

If it returns null"null"

Otherwise, returns class2type[class2type.toString(obj)]

Zepto in the code to initialize the class2type object initialization:

$.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
    class2type[ "[object " + name + "]" ] = name.toLowerCase()
})

function compact

Returns an array containing no null and undefined (undefined = = null is true, 0 = = nul and '= = null is false)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Eleanor at November 14, 2013 - 7:59 PM