1.node
document.getElementsByTagName('head')[0]
document.head
2.chrome
3.dom
var IEVersion = NaN if (window.VBArray) { IEVersion = document.documentMode || (window.XMLHttpRequest ? 7 : 6) }
4.this
function returnRandom() { return new Date() - 0 }
5.spa
for (var i = 0, n = array.length; i < n; i++) { // n }
6.firefox
var rword = /[^, ]+/g // ^排除 ' m, f'.match(rword) // ["m", "f"] var class2type = {} "Boolean Number String Function Array Date RegExp Object Error".replace(rword, function (name) { class2type["[object " + name + "]"] = name.toLowerCase() }) class2type
7.code
avalon.each({ scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function (method, prop) { avalon.fn[method] = function (val) { var node = this[0] || {}, win = getWindow(node), top = method === "scrollTop" if (!arguments.length) { return win ? win[prop] : node[method] } else { if (win) { // scrollTo(xpos,ypos) win.scrollTo(!top ? val : win[prop], top ? val : win[prop]) } else { node[method] = val } } } })
8.blog
var eventHooks = { "mouseenter": { type: "mouseover", fix: function(elem, fn) { return function (e) { var t = e.relatedTarget if (!t || (t !== elem && !(elem.compareDocumentPosition(t) & 16))) { delete e.type e.type = "mouseenter" return fn.call(elem, e) } } } } } function bind(el, type, fn, phase) { var hooks = eventHooks var hook = hooks[type] if (typeof hook === "object") { type = hook.type || type phase = hook.phase || !!phase fn = hook.fix ? hook.fix(el, fn) : fn } el.addEventListener(type, fn, phase) return fn } bind(document.querySelector('#box'), 'click', function(e) { console.log(this) console.log(e) }) bind(document.querySelector('#box'), 'mouseenter', function(e) { console.log(this) console.log(e) })
9.seo
if (DOC.onmousewheel === void 0) { /* IE6-11 chrome mousewheel wheelDetla 下 -120 上 120 firefox DOMMouseScroll detail 下3 上-3 firefox wheel detlaY 下3 上-3 IE9-11 wheel deltaY 下40 上-40 chrome wheel deltaY 下100 上-100 */ eventHooks.mousewheel = { type: "wheel", fix: function (elem, fn) { return function (e) { e.wheelDeltaY = e.wheelDelta = e.deltaY > 0 ? -120 : 120 e.wheelDeltaX = 0 Object.defineProperty(e, "type", { value: "mousewheel" }) fn.call(elem, e) } } } }
10.get
11.
12.
while (fn = readyList.shift()) { fn(avalon) }