-
Notifications
You must be signed in to change notification settings - Fork 68
FED-2812 Catch MouseEvent.dataTransfer null exception #398
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Its possible in JS for MouseEvent.dataTransfer to be null - but in Dart SDK’s interop, its non nullable.
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on Slack: #support-infosec. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+10
@Workiva/release-management-pp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 from RM
The Problem
In Dart SDK versions with null-safety enabled, the interop for
MouseEvent.dataTransfer
is non-nullable despite the JS spec fordataTransfer
clearly indicating that it can be null.This can cause the SDK to throw when a
MouseEvent
is manually constructed (e.g. in a test utility), and thedataTransfer
getter is then accessed when running withsound_null_safety
enabled:The Solution
While we cannot fix the native
MouseEvent.dataTransfer
issue directly, we can monkey patch this flawed non-null assertion for theSyntheticMouseEvent.dataTransfer
property that all of our consumer's UI / tests will be accessing as they migrate to null safety.This PR adds an extension method that catches the Dart SDK's exception in a new
safeDataTransfer
getter, and updates thewrapNativeMouseEvent
implementation to makeSyntheticMouseEvent.dataTransfer
access the newsafeDataTransfer
getter instead of the nativeMouseEvent.dataTransfer
directly.QA