diff --git a/core/event/event-manager.js b/core/event/event-manager.js index 644259b44a..fa5ebdb8c2 100644 --- a/core/event/event-manager.js +++ b/core/event/event-manager.js @@ -28,7 +28,8 @@ var Montage = require("../core").Montage, Event_BUBBLING_PHASE = 3, defaultEventManager, browserSupportsCaptureOption = false, - browserSupportsPassiveOption = false; + browserSupportsPassiveOption = false, + MontageElement = window ? window.MontageElement : null; @@ -3070,11 +3071,11 @@ var EventManager = exports.EventManager = Montage.specialize(/** @lends EventMan // console.log("handleEvent "+event.type,event.target); // } //console.log("----> handleEvent "+event.type); - if(isBrowser) { - if ((window.MontageElement && event.target instanceof MontageElement) || - (event instanceof UIEvent && !this._shouldDispatchEvent(event))) { + if(isBrowser && ( + (MontageElement && event.target instanceof MontageElement) || + (event instanceof UIEvent && !this._shouldDispatchEvent(event)) + )) { return void 0; - } } // performance.mark('event-manager:handleEvent:start'); @@ -3095,18 +3096,18 @@ var EventManager = exports.EventManager = Montage.specialize(/** @lends EventMan eventType = event.type, // capitalizedEventType = eventType.toCapitalized(), eventBubbles = event.bubbles, - captureMethodName, - bubbleMethodName, - identifierSpecificCaptureMethodName, - identifierSpecificBubbleMethodName, - currentTargetIdentifierSpecificCaptureMethodName, - currentTargetIdentifierSpecificBubbleMethodName, - capitalizedIdentifier, + // captureMethodName, + // bubbleMethodName, + // identifierSpecificCaptureMethodName, + // identifierSpecificBubbleMethodName, + // currentTargetIdentifierSpecificCaptureMethodName, + // currentTargetIdentifierSpecificBubbleMethodName, + // capitalizedIdentifier, mutableEvent, mutableEventTarget, _currentDispatchedTargetListeners = this._currentDispatchedTargetListeners, - registeredCaptureEventListeners = this._registeredCaptureEventListeners, - registeredBubbleEventListeners = this._registeredBubbleEventListeners, + // registeredCaptureEventListeners = this._registeredCaptureEventListeners, + // registeredBubbleEventListeners = this._registeredBubbleEventListeners, //New stuff CAPTURING_PHASE = Event_CAPTURING_PHASE, @@ -3172,8 +3173,10 @@ var EventManager = exports.EventManager = Montage.specialize(/** @lends EventMan // Capture Phase Distribution mutableEvent.eventPhase = CAPTURING_PHASE; // The event path we generate is from bottom to top, capture needs to traverse this backwards - for (i = eventPath.length - 1; !mutableEvent.propagationStopped && (iTarget = eventPath[i]); i--) { - mutableEvent.currentTarget = iTarget; + i = eventPath.length; + while (!mutableEvent.propagationStopped && (iTarget = eventPath[--i])) { + //for (i = eventPath.length - 1; !mutableEvent.propagationStopped && (iTarget = eventPath[i]); i--) { + mutableEvent.currentTarget = iTarget; listenerEntries = this._registeredEventListenersOnTarget_eventType_eventPhase(iTarget, eventType, CAPTURING_PHASE); if (!listenerEntries) { @@ -3326,7 +3329,7 @@ var EventManager = exports.EventManager = Montage.specialize(/** @lends EventMan //TEST, shutting currentTargetIdentifierSpecificPhaseMethodName down: - currentTargetIdentifierSpecificPhaseMethodName = null; + //currentTargetIdentifierSpecificPhaseMethodName = null; if(typeof listener === this._functionType) { listener.call(iTarget, mutableEvent);