Add method stopPropagation and stop to NavigationEvent

Summary: @​public

Add method `stopPropagation` and `stop` to NavigationEvent so we can stop event easily once event bubbling and capturing is supported.

Reviewed By: @fkgozali

Differential Revision: D2471903
This commit is contained in:
Hedger Wang 2015-09-23 19:51:08 -07:00 committed by facebook-github-bot-9
parent a0ccebc460
commit 200d9af315

View File

@ -57,6 +57,7 @@ var _navigationEventPool = new NavigationEventPool();
class NavigationEvent {
_data: any;
_defaultPrevented: boolean;
_propagationStopped: boolean;
_disposed: boolean;
_target: ?Object;
_type: ?string;
@ -71,6 +72,7 @@ class NavigationEvent {
this._data = data;
this._defaultPrevented = false;
this._disposed = false;
this._propagationStopped = false;
}
/* $FlowFixMe - get/set properties not yet supported */
@ -97,6 +99,19 @@ class NavigationEvent {
this._defaultPrevented = true;
}
stopPropagation(): void {
this._propagationStopped = true;
}
stop(): void {
this.preventDefault();
this.stopPropagation();
}
isPropagationStopped(): boolean {
return this._propagationStopped;
}
/**
* Dispose the event.
* NavigationEvent shall be disposed after being emitted by