From 98a6f19d7c41e1d4fd3c04d07bb2c4e627f21724 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 2 Oct 2018 15:02:07 -0700 Subject: [PATCH] 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 --- ReactCommon/fabric/events/EventEmitter.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ReactCommon/fabric/events/EventEmitter.cpp b/ReactCommon/fabric/events/EventEmitter.cpp index ce88bc1edfe..339031db4fa 100644 --- a/ReactCommon/fabric/events/EventEmitter.cpp +++ b/ReactCommon/fabric/events/EventEmitter.cpp @@ -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; }