jquery 2.1.4版本的原始碼分析
jquery中獲取元素的原始碼分析
jquery.each(,//獲取所有的 父節點 這涉及到 dir 方法
parents:
function
(elem) ,
parentsuntil:
function
(elem, i, until) ,
next:
function
(elem) ,
prev:
function
(elem) ,
nextall:
function
(elem) ,
prevall:
function
(elem) ,
nextuntil:
function
(elem, i, until) ,
prevuntil:
function
(elem, i, until) ,
//返回所有的兄弟節點
siblings:
function
(elem) ).firstchild, elem);
},children:
function
(elem) ,
//返回框架裡面的所有內容 或者 元素的所有子節點
contents:
function
(elem)
}, function
(name, fn)
if(selector && typeof selector === "string")
if(this.length > 1)
//reverse order for parents* and prev-derivatives
if(rparentsprev.test(name))
}return
this
.pushstack(matched);
};});
jquery.extend(matched.push(elem);}}
return
matched;
},//通過上面的原始碼next方法可知 elem = nextsiblilng
sibling:
function
(n, elem)
}return
matched;
}});
這裡說一下 nextsibling 與 nextelementsibling的區別
nextsibling :返回元素之後的兄弟節點 (包含 注釋 文字)
nextelementsibling:返回元素之後的兄弟節點 不包括注釋 跟文字 且他的屬性只為讀
jquery.noconflict原始碼分析
var//將jquery掛載到windows物件下
_jquery =window.jquery,
//將$掛載到windows物件下
_$ =window.$;
// 當呼叫 jquery.noconfict deep ==false 那麼 $ 別名失效 如果 deep==true 那麼 jquery 的別名失效
jquery.noconflict = function
(deep)
if(deep && window.jquery ===jquery)
return
jquery;
};//expose jquery and $ identifiers, even in amd
//(#7102#comment:10,
//and commonjs for browser emulators (#13566)
if(typeof noglobal ===strundefined) {
window.jquery = window.$ = jquery;
2016-11-22 21:14:38
jquery原始碼分析(2)(2 0版本)
1.引數為什麼傳window和undefined function window,undefined window 1.1 根據作用域鏈的原理,傳入window引數之後,能提高查詢速度。2 便於壓縮。2.傳入undefined,防止undefined在外部被修改。2.變數rootjquery,cor...
dubbo 原始碼解析 2 5 3版本
1.channeleventrunnable類 通道訊息執行緒 所有的訊息都在此處理,包含訊息的收,發,斷開連線,異常等 public class channeleventrunnable implements runnable public channeleventrunnable channel...
深究1 8版本HashMap原始碼
public v put k key,v value 在putval方法之前,對 key 進行了 hash 計算。static final inthash object key 通過 hashcode 方法和無符號左移16後的 hashcode 進行異或計算。進行了一次擾動計算。再看 putval ...