(function( window, undefined ) {
var jQuery = (function() {
// 構(gòu)建jQuery對(duì)象
var jQuery = function( selector, context ) {
return new jQuery.fn.init( selector, context, rootjQuery );
}
// jQuery對(duì)象原型
jQuery.fn = jQuery.prototype = {
constructor: jQuery,
init: function( selector, context, rootjQuery ) {
// selector有以下7種分支情況:
// DOM元素
// body(優(yōu)化)
// 字符串:HTML標(biāo)簽、HTML字符串、#id、選擇器表達(dá)式
// 函數(shù)(作為ready回調(diào)函數(shù))
// 最后返回偽數(shù)組
}
};
// Give the init function the jQuery prototype for later instantiation
jQuery.fn.init.prototype = jQuery.fn;
// 合并內(nèi)容到第一個(gè)參數(shù)中,后續(xù)大部分功能都通過該函數(shù)擴(kuò)展
// 通過jQuery.fn.extend擴(kuò)展的函數(shù),大部分都會(huì)調(diào)用通過jQuery.extend擴(kuò)展的同名函數(shù)
jQuery.extend = jQuery.fn.extend = function() {};
// 在jQuery上擴(kuò)展靜態(tài)方法
jQuery.extend({
// ready bindReady
// isPlainObject isEmptyObject
// parseJSON parseXML
// globalEval
// each makeArray inArray merge grep map
// proxy
// access
// uaMatch
// sub
// browser
});
// 到這里,jQuery對(duì)象構(gòu)造完成,后邊的代碼都是對(duì)jQuery或jQuery對(duì)象的擴(kuò)展
return jQuery;
})();
window.jQuery = window.$ = jQuery;
})(window);