Move 'top' prefix from UIManager to EventEmitter

Summary: This diff unifies the 'handling' of the top prefix in the EventEmitter.cpp class

Reviewed By: shergin

Differential Revision: D10149497

fbshipit-source-id: d0ddbbbeefe3790b414b101da47582161354c971
This commit is contained in:
David Vacca 2018-10-02 15:02:07 -07:00 committed by Facebook Github Bot
parent cf66923831
commit 98a6f19d7c
1 changed files with 6 additions and 4 deletions

View File

@ -16,13 +16,15 @@ namespace react {
// TODO(T29874519): Get rid of "top" prefix once and for all.
/*
* Capitalizes the first letter of the event type and adds "top" prefix
* (e.g. "layout" becames "topLayout").
* Capitalizes the first letter of the event type and adds "top" prefix if
* necessary (e.g. "layout" becames "topLayout").
*/
static std::string normalizeEventType(const std::string &type) {
auto prefixedType = type;
prefixedType[0] = toupper(prefixedType[0]);
prefixedType.insert(0, "top");
if (type.find("top", 0) != 0) {
prefixedType.insert(0, "top");
prefixedType[3] = toupper(prefixedType[3]);
}
return prefixedType;
}