MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / eventHandler

Function eventHandler

code/songhop/www/lib/angular/angular.js:2961–3001  ·  view source on GitHub ↗
(event, type)

Source from the content-addressed store, hash-verified

2959
2960function createEventHandler(element, events) {
2961 var eventHandler = function(event, type) {
2962 // jQuery specific api
2963 event.isDefaultPrevented = function() {
2964 return event.defaultPrevented;
2965 };
2966
2967 var eventFns = events[type || event.type];
2968 var eventFnsLength = eventFns ? eventFns.length : 0;
2969
2970 if (!eventFnsLength) return;
2971
2972 if (isUndefined(event.immediatePropagationStopped)) {
2973 var originalStopImmediatePropagation = event.stopImmediatePropagation;
2974 event.stopImmediatePropagation = function() {
2975 event.immediatePropagationStopped = true;
2976
2977 if (event.stopPropagation) {
2978 event.stopPropagation();
2979 }
2980
2981 if (originalStopImmediatePropagation) {
2982 originalStopImmediatePropagation.call(event);
2983 }
2984 };
2985 }
2986
2987 event.isImmediatePropagationStopped = function() {
2988 return event.immediatePropagationStopped === true;
2989 };
2990
2991 // Copy event handlers in case event handlers array is modified during execution.
2992 if ((eventFnsLength > 1)) {
2993 eventFns = shallowCopy(eventFns);
2994 }
2995
2996 for (var i = 0; i < eventFnsLength; i++) {
2997 if (!event.isImmediatePropagationStopped()) {
2998 eventFns[i].call(element, event);
2999 }
3000 }
3001 };
3002
3003 // TODO: this is a hack for angularMocks/clearDataCache that makes it possible to deregister all
3004 // events on `element`

Callers

nothing calls this directly

Calls 2

isUndefinedFunction · 0.70
shallowCopyFunction · 0.70

Tested by

no test coverage detected