Skip to content
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

Merged
merged 11 commits into from
Nov 19, 2018

Conversation

davidturissini
Copy link
Contributor

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?

  • Yes
  • No

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

@davidturissini davidturissini changed the title Dturissini/focused event retarget fix(engine): relatedTarget event regargeting Nov 16, 2018
@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 2f579f6 | Target commit: 742ca4e

lwc-engine-benchmark

table-append-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table/append/1k duration 147.70 (±3.90 ms) 148.40 (±4.50 ms) +0.7ms (0.5%) 👌
table-clear-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table/clear/1k duration 6.10 (±0.45 ms) 5.90 (±0.40 ms) -0.2ms (3.3%) 👍
table-create-10k metric base(2f579f6) target(742ca4e) trend
benchmark-table/create/10k duration 892.25 (±6.35 ms) 873.35 (±7.85 ms) -18.9ms (2.1%) 👍
table-create-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table/create/1k duration 117.70 (±1.65 ms) 115.55 (±2.55 ms) -2.2ms (1.8%) 👍
table-update-10th-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table/update-10th/1k duration 76.20 (±1.65 ms) 87.30 (±3.25 ms) +11.1ms (14.6%) 👎
tablecmp-append-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table-component/append/1k duration 245.35 (±9.40 ms) 248.95 (±6.85 ms) +3.6ms (1.5%) 👌
tablecmp-clear-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table-component/clear/1k duration 12.15 (±1.60 ms) 11.70 (±1.65 ms) -0.4ms (3.7%) 👌
tablecmp-create-10k metric base(2f579f6) target(742ca4e) trend
benchmark-table-component/create/10k duration 1734.00 (±11.75 ms) 1695.00 (±12.35 ms) -39.0ms (2.2%) 👍
tablecmp-create-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table-component/create/1k duration 207.75 (±6.30 ms) 210.35 (±5.05 ms) +2.6ms (1.3%) 👌
tablecmp-update-10th-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table-component/update-10th/1k duration 71.75 (±5.55 ms) 73.70 (±4.60 ms) +2.0ms (2.7%) 👌
wc-append-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table-wc/append/1k duration 255.45 (±7.40 ms) 254.80 (±7.85 ms) -0.6ms (0.3%) 👌
wc-clear-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table-wc/clear/1k duration 23.25 (±1.80 ms) 23.05 (±2.65 ms) -0.2ms (0.9%) 👍
wc-create-10k metric base(2f579f6) target(742ca4e) trend
benchmark-table-wc/create/10k duration 1801.85 (±34.00 ms) 1784.80 (±29.80 ms) -17.0ms (0.9%) 👌
wc-create-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table-wc/create/1k duration 225.50 (±4.60 ms) 226.85 (±4.80 ms) +1.3ms (0.6%) 👌
wc-update-10th-1k metric base(2f579f6) target(742ca4e) trend
benchmark-table-wc/update-10th/1k duration 71.45 (±5.45 ms) 73.40 (±3.70 ms) +2.0ms (2.7%) 👌

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 2f579f6 | Target commit: 0679d30

lwc-engine-benchmark

table-append-1k metric base(2f579f6) target(0679d30) trend
benchmark-table/append/1k duration 147.70 (±3.90 ms) 149.60 (±4.85 ms) +1.9ms (1.3%) 👌
table-clear-1k metric base(2f579f6) target(0679d30) trend
benchmark-table/clear/1k duration 6.10 (±0.45 ms) 6.35 (±0.35 ms) +0.3ms (4.1%) 👌
table-create-10k metric base(2f579f6) target(0679d30) trend
benchmark-table/create/10k duration 892.25 (±6.35 ms) 871.50 (±7.20 ms) -20.8ms (2.3%) 👍
table-create-1k metric base(2f579f6) target(0679d30) trend
benchmark-table/create/1k duration 117.70 (±1.65 ms) 117.40 (±3.85 ms) -0.3ms (0.3%) 👌
table-update-10th-1k metric base(2f579f6) target(0679d30) trend
benchmark-table/update-10th/1k duration 76.20 (±1.65 ms) 89.25 (±1.55 ms) +13.0ms (17.1%) 👎
tablecmp-append-1k metric base(2f579f6) target(0679d30) trend
benchmark-table-component/append/1k duration 245.35 (±9.40 ms) 249.65 (±6.65 ms) +4.3ms (1.8%) 👎
tablecmp-clear-1k metric base(2f579f6) target(0679d30) trend
benchmark-table-component/clear/1k duration 12.15 (±1.60 ms) 12.20 (±1.80 ms) +0.1ms (0.4%) 👌
tablecmp-create-10k metric base(2f579f6) target(0679d30) trend
benchmark-table-component/create/10k duration 1734.00 (±11.75 ms) 1705.95 (±12.15 ms) -28.1ms (1.6%) 👍
tablecmp-create-1k metric base(2f579f6) target(0679d30) trend
benchmark-table-component/create/1k duration 207.75 (±6.30 ms) 206.50 (±5.30 ms) -1.3ms (0.6%) 👌
tablecmp-update-10th-1k metric base(2f579f6) target(0679d30) trend
benchmark-table-component/update-10th/1k duration 71.75 (±5.55 ms) 71.55 (±5.50 ms) -0.2ms (0.3%) 👌
wc-append-1k metric base(2f579f6) target(0679d30) trend
benchmark-table-wc/append/1k duration 255.45 (±7.40 ms) 253.50 (±9.10 ms) -1.9ms (0.8%) 👌
wc-clear-1k metric base(2f579f6) target(0679d30) trend
benchmark-table-wc/clear/1k duration 23.25 (±1.80 ms) 22.10 (±2.30 ms) -1.1ms (4.9%) 👌
wc-create-10k metric base(2f579f6) target(0679d30) trend
benchmark-table-wc/create/10k duration 1801.85 (±34.00 ms) 1799.75 (±33.10 ms) -2.1ms (0.1%) 👌
wc-create-1k metric base(2f579f6) target(0679d30) trend
benchmark-table-wc/create/1k duration 225.50 (±4.60 ms) 218.65 (±5.15 ms) -6.8ms (3.0%) 👍
wc-update-10th-1k metric base(2f579f6) target(0679d30) trend
benchmark-table-wc/update-10th/1k duration 71.45 (±5.45 ms) 70.90 (±4.45 ms) -0.5ms (0.8%) 👌

@@ -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;
Copy link
Contributor

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.

Copy link
Contributor

@caridy caridy left a 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

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: a16b399 | Target commit: 613130d

lwc-engine-benchmark

table-append-1k metric base(a16b399) target(613130d) trend
benchmark-table/append/1k duration 150.10 (±4.35 ms) 148.10 (±3.60 ms) -2.0ms (1.3%) 👌
table-clear-1k metric base(a16b399) target(613130d) trend
benchmark-table/clear/1k duration 5.90 (±0.30 ms) 5.95 (±0.35 ms) +0.0ms (0.8%) 👌
table-create-10k metric base(a16b399) target(613130d) trend
benchmark-table/create/10k duration 867.30 (±6.70 ms) 883.25 (±6.80 ms) +16.0ms (1.8%) 👎
table-create-1k metric base(a16b399) target(613130d) trend
benchmark-table/create/1k duration 117.00 (±2.10 ms) 117.35 (±2.85 ms) +0.3ms (0.3%) 👌
table-update-10th-1k metric base(a16b399) target(613130d) trend
benchmark-table/update-10th/1k duration 87.30 (±3.00 ms) 76.75 (±2.45 ms) -10.6ms (12.1%) 👍
tablecmp-append-1k metric base(a16b399) target(613130d) trend
benchmark-table-component/append/1k duration 252.25 (±6.00 ms) 239.15 (±13.40 ms) -13.1ms (5.2%) 👍
tablecmp-clear-1k metric base(a16b399) target(613130d) trend
benchmark-table-component/clear/1k duration 12.00 (±1.65 ms) 11.60 (±1.00 ms) -0.4ms (3.3%) 👌
tablecmp-create-10k metric base(a16b399) target(613130d) trend
benchmark-table-component/create/10k duration 1740.05 (±9.95 ms) 1710.50 (±16.10 ms) -29.5ms (1.7%) 👍
tablecmp-create-1k metric base(a16b399) target(613130d) trend
benchmark-table-component/create/1k duration 206.25 (±5.20 ms) 205.20 (±6.10 ms) -1.1ms (0.5%) 👌
tablecmp-update-10th-1k metric base(a16b399) target(613130d) trend
benchmark-table-component/update-10th/1k duration 72.30 (±6.45 ms) 70.30 (±5.40 ms) -2.0ms (2.8%) 👌
wc-append-1k metric base(a16b399) target(613130d) trend
benchmark-table-wc/append/1k duration 249.95 (±14.80 ms) 252.85 (±8.10 ms) +2.9ms (1.2%) 👌
wc-clear-1k metric base(a16b399) target(613130d) trend
benchmark-table-wc/clear/1k duration 22.20 (±2.40 ms) 22.35 (±2.10 ms) +0.2ms (0.7%) 👌
wc-create-10k metric base(a16b399) target(613130d) trend
benchmark-table-wc/create/10k duration 1788.30 (±26.55 ms) 1782.05 (±33.10 ms) -6.3ms (0.3%) 👌
wc-create-1k metric base(a16b399) target(613130d) trend
benchmark-table-wc/create/1k duration 220.20 (±4.25 ms) 218.50 (±4.90 ms) -1.7ms (0.8%) 👌
wc-update-10th-1k metric base(a16b399) target(613130d) trend
benchmark-table-wc/update-10th/1k duration 72.30 (±5.55 ms) 75.90 (±5.20 ms) +3.6ms (5.0%) 👌

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: a16b399 | Target commit: e943db7

lwc-engine-benchmark

table-append-1k metric base(a16b399) target(e943db7) trend
benchmark-table/append/1k duration 150.10 (±4.35 ms) 146.30 (±3.60 ms) -3.8ms (2.5%) 👍
table-clear-1k metric base(a16b399) target(e943db7) trend
benchmark-table/clear/1k duration 5.90 (±0.30 ms) 6.00 (±0.40 ms) +0.1ms (1.7%) 👌
table-create-10k metric base(a16b399) target(e943db7) trend
benchmark-table/create/10k duration 867.30 (±6.70 ms) 863.75 (±7.70 ms) -3.5ms (0.4%) 👌
table-create-1k metric base(a16b399) target(e943db7) trend
benchmark-table/create/1k duration 117.00 (±2.10 ms) 116.80 (±2.85 ms) -0.2ms (0.2%) 👌
table-update-10th-1k metric base(a16b399) target(e943db7) trend
benchmark-table/update-10th/1k duration 87.30 (±3.00 ms) 76.10 (±2.25 ms) -11.2ms (12.8%) 👍
tablecmp-append-1k metric base(a16b399) target(e943db7) trend
benchmark-table-component/append/1k duration 252.25 (±6.00 ms) 245.70 (±6.35 ms) -6.6ms (2.6%) 👍
tablecmp-clear-1k metric base(a16b399) target(e943db7) trend
benchmark-table-component/clear/1k duration 12.00 (±1.65 ms) 12.05 (±1.75 ms) +0.1ms (0.4%) 👌
tablecmp-create-10k metric base(a16b399) target(e943db7) trend
benchmark-table-component/create/10k duration 1740.05 (±9.95 ms) 1713.65 (±8.25 ms) -26.4ms (1.5%) 👍
tablecmp-create-1k metric base(a16b399) target(e943db7) trend
benchmark-table-component/create/1k duration 206.25 (±5.20 ms) 207.10 (±4.95 ms) +0.8ms (0.4%) 👌
tablecmp-update-10th-1k metric base(a16b399) target(e943db7) trend
benchmark-table-component/update-10th/1k duration 72.30 (±6.45 ms) 70.30 (±4.80 ms) -2.0ms (2.8%) 👍
wc-append-1k metric base(a16b399) target(e943db7) trend
benchmark-table-wc/append/1k duration 249.95 (±14.80 ms) 254.35 (±11.50 ms) +4.4ms (1.8%) 👌
wc-clear-1k metric base(a16b399) target(e943db7) trend
benchmark-table-wc/clear/1k duration 22.20 (±2.40 ms) 22.85 (±3.45 ms) +0.7ms (2.9%) 👌
wc-create-10k metric base(a16b399) target(e943db7) trend
benchmark-table-wc/create/10k duration 1788.30 (±26.55 ms) 1818.25 (±41.05 ms) +30.0ms (1.7%) 👎
wc-create-1k metric base(a16b399) target(e943db7) trend
benchmark-table-wc/create/1k duration 220.20 (±4.25 ms) 221.80 (±5.15 ms) +1.6ms (0.7%) 👌
wc-update-10th-1k metric base(a16b399) target(e943db7) trend
benchmark-table-wc/update-10th/1k duration 72.30 (±5.55 ms) 70.75 (±4.35 ms) -1.5ms (2.1%) 👌

@diervo diervo merged commit 2906ed8 into master Nov 19, 2018
@diervo diervo deleted the dturissini/focused-event-retarget branch November 19, 2018 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants