首页 > 代码库 > jQuery源代码学习之九—jQuery事件模块

jQuery源代码学习之九—jQuery事件模块

jQuery事件系统并没有将事件坚挺函数直接绑定在DOM元素上,而是基于事件缓存模块来管理监听函数的。

二、jQuery事件模块的代码结构

 

   //定义了一些正则    //    //    //jQuery事件对象    jQuery.event={        global:{},        add:function(elem,types,handle,data,selector){},        remove:function(elem,types,handler,selector,mapppedTypes){},        trigger:function(event,data,elem,onlyHandlers){},        dispatch:function(event){},        handlers:function(event,handlers){},        props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),        fixHooks:{},        keyHooks:{            props: "char charCode key keyCode".split(" "),            filter:function(event,original){}        },        mouseHooks:{            props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),            filter:function(event,original){},        },        fix:function(event){},        special:{            load:{},            focus:{                trigger:function(){},                delegateType:‘‘,            },            blur:{                trigger:function(){},                delegateType:‘‘,            }            click:{                trigger:function(){},                _default:function(event){}            }            beforeunload:{              postDispatch:function(event){},              }            simulate:function(type,elem,event,bubble){}        },    };    jQuery.removeEvent=function(elem,type,handler){};    jQuery.Event=function(src,props){};    jQuery.Event.prototype={        isDefaultPrevented:,        isPropagationStopped:,        isImmediatePropagationStopped:,        preventDefault:function(){},        stopPropagation:function(){},        stopImmediatePropagation:function(){},    };    jQuery.fn.extend({        on:function(types,selector,data,fn,one){},        one:function(types,selector,data,fn){},        off:function(types,selector,fn){},        trigger:function(type,data){},        triggerHandler:function(type,data){}    });    

 

jQuery源代码学习之九—jQuery事件模块