Skip to content

Commit

Permalink
perf: Avoid native call to get parent while bubbling events
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Apr 17, 2023
1 parent 18a2b47 commit 50cc2a3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Uno.UI/UI/Xaml/UIElement.RoutedEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -719,11 +719,13 @@ internal bool RaiseEvent(RoutedEvent routedEvent, RoutedEventArgs args, Bubbling
args.CanBubbleNatively = false;
}

#if __IOS__ || __ANDROID__
var parent = this.FindFirstParent<UIElement>();
#else
var parent = this.GetParent() as UIElement;
#if __IOS__ || __ANDROID__
// This is for safety (legacy support) and should be removed.
// A common issue is the managed parent being cleared before unload event raised.
parent ??= this.FindFirstParent<UIElement>();
#endif

// [11] A parent is defined?
if (parent == null)
{
Expand Down

0 comments on commit 50cc2a3

Please sign in to comment.