jquery源码分析(2) JQuery的基本变量和函数3

来源:互联网 发布:金山数据恢复 账号 编辑:程序博客网 时间:2024/05/23 12:05

本文将分析(21 , 94) 定义了一些变量和函数 jquery = function(){};


分析的具体部分的源码(67-94)  【因为包含注释可能行号有所误差 (>^ω^<)


// Used for matching numberscore_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,// Used for splitting on whitespacecore_rnotwhite = /\S+/g,// A simple way to check for HTML strings// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)// Strict HTML recognition (#11290: must start with <)rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,// Match a standalone tagrsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,// Matches dashed string for camelizingrmsPrefix = /^-ms-/,rdashAlpha = /-([\da-z])/gi,// Used by jQuery.camelCase as callback to replace()fcamelCase = function( all, letter ) {return letter.toUpperCase();},// The ready event handler and self cleanup methodcompleted = function() {document.removeEventListener( "DOMContentLoaded", completed, false );window.removeEventListener( "load", completed, false );jQuery.ready();};


       //以下为一些正则表达式
// Used for matching numbers
core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,  //匹配一些数字


// Used for splitting on whitespace
core_rnotwhite = /\S+/g,  //匹配空格


// A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
// Strict HTML recognition (#11290: must start with <)
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,  //匹配标签或id防止XSS


// Match a standalone tag
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,  //匹配成对出现的标签


// Matches dashed string for camelizing
rmsPrefix = /^-ms-/, //匹配微软
rdashAlpha = /-([\da-z])/gi, //匹配驼峰写法 正常情况下 如-webkit-marign-left对应webkitMarginLeft但微软会转成MsMarignLeft即第一个字符大写


// Used by jQuery.camelCase as callback to replace()
fcamelCase = function( all, letter ) {
return letter.toUpperCase();
},  //转驼峰的回调函数


// The ready event handler and self cleanup method
completed = function() {
document.removeEventListener( "DOMContentLoaded", completed, false );
window.removeEventListener( "load", completed, false );
jQuery.ready();
};  //dom加载成功触发这个函数


第一部分分析(21 , 94) 定义了一些变量和函数 jquery = function(){}; 完结! 

0 0