您的位置:首页 > Web前端 > JQuery

01.阅读JQUERY源码——定义函数

2016-03-14 22:50 661 查看
(function(window,undefined){
var
rootjQuery,
readyList,
core_strundefined =typeof undefined,
location =window.location,
document =window.document,
docElem =window.documentElement,
_jQuery =window.jQuery,
_$ = window.$,

class2type = {},
//无用了
core_deletedIds = [],
core_version = "2.0.3",
//Save a reference to some core metheds
core_concat =core_deletedIds.concat,
core_push=core_deletedIds.push,
core_slice =core_deletedIds.slice,
core_indexOf =core_deletedIds.indexOf,
core_toString = class2type.hasOwnProperty,
core_trim =core_version.trim,
//定义jQ函数
jQuery = function(selector,context){
return new jQuery.fn.init(selector,context,rootjQuery);
},

//正则 暂缺

})(window)

/*————————————解析————————————————————————————*/
/*传window*/
1/速度更快
2/传参e取代window(压缩版)
/*传undefined*/
1/防止undefined被修改

/*严格模式下需要规范,否则会报错*/
"use strict"

/*不充分判断(IE9以下)*/
window.a == undefined
/*全兼容判断*/
typeof window.a == undefined

/*jQuery的对象设计方式*/
jQuery.fn=jQuery.prototype;
function jQuery(){
return new jQuery.prototype.init();
}
jQuery.prototype.init =function(){}
jQuery.prototype.css =function(){}
jQuery.prototype.init.prototype = jQuery.prototype;
jQuery().css();
/*———————————————————————————————————————————————*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: