mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Fix event timestamp injection to check both casing variants (#56495)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56495 UIManagerBinding::dispatchEvent checks for an existing timeStamp property before injecting one, but only checks the camelCase variant. Native events that use lowercase timestamp (e.g. pointer events) would have a duplicate timeStamp injected with the current time, which then takes precedence in the SyntheticEvent timestamp resolution chain (event.timeStamp || event.timestamp). This adds a check for both timeStamp and timestamp before auto-injecting, preserving the original native event timestamp when present in either casing. Root cause: https://github.com/facebook/react-native/pull/55878 only checked for timeStamp (camelCase). Changelog: [General][Fixed] - Fix event timestamp injection overriding native timestamps with lowercase property name Reviewed By: mdvacca Differential Revision: D101522871 fbshipit-source-id: 74d91a3958ac73927251189f07f954303d45688e
This commit is contained in:
1 parent
5620b1ba11
commit
68debb27ff
1 file changed
+2
-1
@@ -147,7 +147,8 @@ void UIManagerBinding::dispatchEventToJS(
|
||||
// Add timestamp to payload if not already set
|
||||
if (payload.isObject()) {
|
||||
auto payloadObject = payload.asObject(runtime);
|
||||
if (!payloadObject.hasProperty(runtime, "timeStamp")) {
|
||||
if (!payloadObject.hasProperty(runtime, "timeStamp") &&
|
||||
!payloadObject.hasProperty(runtime, "timestamp")) {
|
||||
payloadObject.setProperty(
|
||||
runtime, "timeStamp", eventTimestamp.toDOMHighResTimeStamp());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user