-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(engine): relatedTarget event regargeting #842
Conversation
Benchmark resultsBase commit: lwc-engine-benchmark
|
return originalTarget; | ||
// and when an event has been added to Window | ||
if (!(originalCurrentTarget instanceof Node)) { | ||
return retarget(document, pathComposer(document as Node, this.composed)) as EventTarget; |
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.
I think the pathComposer() should be invoked with originalTarget, the retarget() is correctly invoked with the document, so, it will always report the outer most custom element as the actual target.
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.
I thought the same, but it looks like the correct call is:
retarget(document, pathComposer(originalTarget as Node, this.composed))
retarget
will return the first match from pathComposer
that exists in the same light DOM as document
Benchmark resultsBase commit: lwc-engine-benchmark
|
@@ -73,7 +73,7 @@ const EventPatchDescriptors: PropertyDescriptorMap = { | |||
// Handle cases where the currentTarget is null (for async events), | |||
// and when an event has been added to Window | |||
if (!(originalCurrentTarget instanceof Node)) { | |||
return retarget(document, pathComposer(document as Node, this.composed)) as EventTarget; | |||
return retarget(document, pathComposer(originalTarget as Node, this.composed)) as EventTarget; |
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.
since we need this anyways in both parts of the condition, maybe moving tthe pathComposer call up.
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.
just a perf optimization
Benchmark resultsBase commit: lwc-engine-benchmark
|
Benchmark resultsBase commit: lwc-engine-benchmark
|
Details
Retargeting logic for relatedTarget
In place of #837
I don't know how, but the history on that branch got borked so easier to just open a new PR
Does this PR introduce a breaking change?
relatedTarget
will change the value it reports, which is breaking. However, I don't anticipate this being a very widely used feature so any breakages should be minimal