jQuery 1.0.4 New Wave Javascript(js源文件)

2020-05-19 07:32:46易采站长站整理

    this.set( a.constructor == Array || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType ?
        // Assume that it is an array of DOM Elements
        jQuery.merge( a, [] ) :
        // Find the matching elements and save them for later
        jQuery.find( a, c ) );
    // See if an extra function was provided
    var fn = arguments[ arguments.length – 1 ];
    // If so, execute it in context
    if ( fn && typeof fn == “function” )
        this.each(fn);
    return this;
};
// Map over the $ in case of overwrite
if ( typeof $ != “undefined” )
    jQuery._$ = $;
// Map the jQuery namespace to the ‘$’ one
var $ = jQuery;

jQuery.fn = jQuery.prototype = {
    jquery: “1.0.4”,

    size: function() {
        return this.length;
    },

    get: function( num ) {
        return num == undefined ?
            // Return a ‘clean’ array
            jQuery.merge( this, [] ) :
            // Return just the object
            this[num];
    },
    set: function( array ) {
        // Use a tricky hack to make the jQuery object
        // look and feel like an array
        this.length = 0;
        [].push.apply( this, array );