[jQuery] jQuery内核

(1)创建全局jQuery对象

(function(global,document){
    jQuery.prototype=InstanceCreation.prototype;
    jQuery.extend=jQuery.prototype.extend=extend;
    
    function jQuery(selector){
        return new InstanceCreation(selector);
    }
    
    function InstanceCreation(selector){
        var instance=this;
            
        instance[0]=document.querySelector(selector);
        return this;
    }
    
    function extend(material){
        var depository=this;
    
        for(var property in material){
            if(!material.hasOwnProperty(property)){
                continue;
            }
            
            depository[property]=material[property];
        }
        
        return this;
    };
    
    //export:
    global.jQuery=jQuery;
}(window,document));

(2)扩展jQuery.prototype,然后调用




你可能感兴趣的:([jQuery] jQuery内核)