MCPcopy
hub / github.com/Postcatlab/postcat / eventHandler

Function eventHandler

src/workbench/browser/src/ng1/lib/angular/angular.js:3927–3970  ·  view source on GitHub ↗
(event, type)

Source from the content-addressed store, hash-verified

3925
3926 function createEventHandler(element, events) {
3927 var eventHandler = function (event, type) {
3928 // jQuery specific api
3929 event.isDefaultPrevented = function () {
3930 return event.defaultPrevented;
3931 };
3932
3933 var eventFns = events[type || event.type];
3934 var eventFnsLength = eventFns ? eventFns.length : 0;
3935
3936 if (!eventFnsLength) return;
3937
3938 if (isUndefined(event.immediatePropagationStopped)) {
3939 var originalStopImmediatePropagation = event.stopImmediatePropagation;
3940 event.stopImmediatePropagation = function () {
3941 event.immediatePropagationStopped = true;
3942
3943 if (event.stopPropagation) {
3944 event.stopPropagation();
3945 }
3946
3947 if (originalStopImmediatePropagation) {
3948 originalStopImmediatePropagation.call(event);
3949 }
3950 };
3951 }
3952
3953 event.isImmediatePropagationStopped = function () {
3954 return event.immediatePropagationStopped === true;
3955 };
3956
3957 // Some events have special handlers that wrap the real handler
3958 var handlerWrapper = eventFns.specialHandlerWrapper || defaultHandlerWrapper;
3959
3960 // Copy event handlers in case event handlers array is modified during execution.
3961 if ((eventFnsLength > 1)) {
3962 eventFns = shallowCopy(eventFns);
3963 }
3964
3965 for (var i = 0; i < eventFnsLength; i++) {
3966 if (!event.isImmediatePropagationStopped()) {
3967 handlerWrapper(element, event, eventFns[i]);
3968 }
3969 }
3970 };
3971
3972 // TODO: this is a hack for angularMocks/clearDataCache that makes it possible to deregister all
3973 // events on `element`

Callers 1

callEventHandlerFunction · 0.85

Calls 3

isUndefinedFunction · 0.85
shallowCopyFunction · 0.85
callMethod · 0.80

Tested by

no test coverage detected