在不影响事件绑定事件和不影响第三方插件的业务逻辑情况下,跟踪绑定事件的内容,解决内存泄漏问题
;(window => {
const _cathe = window.addEventListener;
window.addList = [];
const handler = {
apply:function(target,thisbinding,args){
Reflect.apply(_cathe,window,args)
window.addList.push(args[0])
console.log(thisbinding)
target()
}
}
window.addEventListener = new Proxy(() => {
console.log(window.addList);
},handler)
})(window)