This repository has been archived on 2023-08-29. You can view files and clone it, but cannot push or open issues/pull-requests.
yutent
/
anot.js
Archived
1
0
Fork 0

移除旧的兼容代码

master
宇天 2019-08-08 19:13:25 +08:00
parent ab03d4a35a
commit 40ff56d26c
3 changed files with 7 additions and 47 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
.LSOverride .LSOverride
.idea .idea
.vscode .vscode
package-lock.json
node_modules/ node_modules/
dist/ dist/

View File

@ -4,7 +4,7 @@ let Anot = function(el) {
} }
/*视浏览器情况采用最快的异步回调*/ /*视浏览器情况采用最快的异步回调*/
Anot.nextTick = new function() { Anot.nextTick = new (function() {
// jshint ignore:line // jshint ignore:line
let tickImmediate = window.setImmediate let tickImmediate = window.setImmediate
let tickObserver = window.MutationObserver let tickObserver = window.MutationObserver
@ -35,7 +35,7 @@ Anot.nextTick = new function() {
return function(fn) { return function(fn) {
setTimeout(fn, 4) setTimeout(fn, 4)
} }
}() // jshint ignore:line })() // jshint ignore:line
/********************************************************************* /*********************************************************************
* Anot的静态方法定义区 * * Anot的静态方法定义区 *
@ -290,7 +290,7 @@ Anot.mix({
t = t.trim() t = t.trim()
let hook = hooks[t] let hook = hooks[t]
if (typeof hook === 'object') { if (typeof hook === 'object') {
type = hook.type || type t = hook.type || type
phase = hook.phase || !!phase phase = hook.phase || !!phase
fn = hook.fix ? hook.fix(el, fn) : fn fn = hook.fix ? hook.fix(el, fn) : fn
} }
@ -307,7 +307,7 @@ Anot.mix({
t = t.trim() t = t.trim()
let hook = hooks[t] let hook = hooks[t]
if (typeof hook === 'object') { if (typeof hook === 'object') {
type = hook.type || type t = hook.type || type
phase = hook.phase || !!phase phase = hook.phase || !!phase
} }
el.removeEventListener(t, fn, phase) el.removeEventListener(t, fn, phase)
@ -349,13 +349,12 @@ Anot.mix({
each: function(obj, fn) { each: function(obj, fn) {
if (obj) { if (obj) {
//排除null, undefined //排除null, undefined
let i = 0
if (isArrayLike(obj)) { if (isArrayLike(obj)) {
for (let n = obj.length; i < n; i++) { for (let i = 0, n = obj.length; i < n; i++) {
if (fn(i, obj[i]) === false) break if (fn(i, obj[i]) === false) break
} }
} else { } else {
for (i in obj) { for (let i in obj) {
if (obj.hasOwnProperty(i) && fn(i, obj[i]) === false) { if (obj.hasOwnProperty(i) && fn(i, obj[i]) === false) {
break break
} }

View File

@ -21,46 +21,6 @@ Anot.contains = function(root, el) {
let eventHooks = Anot.eventHooks let eventHooks = Anot.eventHooks
//针对firefox, chrome修正mouseenter, mouseleave(chrome30+)
if (!('onmouseenter' in root)) {
Anot.each(
{
mouseenter: 'mouseover',
mouseleave: 'mouseout'
},
function(origType, fixType) {
eventHooks[origType] = {
type: fixType,
fix: function(elem, fn) {
return function(e) {
let t = e.relatedTarget
if (!t || (t !== elem && !(elem.compareDocumentPosition(t) & 16))) {
delete e.type
e.type = origType
return fn.call(elem, e)
}
}
}
}
}
)
}
//针对IE9+, w3c修正animationend
Anot.each(
{
AnimationEvent: 'animationend',
WebKitAnimationEvent: 'webkitAnimationEnd'
},
function(construct, fixType) {
if (window[construct] && !eventHooks.animationend) {
eventHooks.animationend = {
type: fixType
}
}
}
)
if (DOC.onmousewheel === void 0) { if (DOC.onmousewheel === void 0) {
/* IE6-11 chrome mousewheel wheelDetla -120 120 /* IE6-11 chrome mousewheel wheelDetla -120 120
firefox DOMMouseScroll detail 下3 -3 firefox DOMMouseScroll detail 下3 -3