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

Add support for passing event options #3769

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

marvinhagemeister
Copy link
Member

@marvinhagemeister marvinhagemeister commented Oct 15, 2022

Example:

const fn = () => console.log("clicked");

<button onClick={[fn, { passive: true }]}>click me</button>

Fixes #428 .

@github-actions
Copy link

github-actions bot commented Oct 15, 2022

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -9% - +16% (-8.20ms - +14.99ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -3% - +5% (-1.92ms - +3.00ms)
    preact-local vs preact-master
  • 07_create10k: unsure 🔍 -1% - +3% (-10.68ms - +56.67ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 -8% - +0% (-2.05ms - +0.11ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -2% - +1% (-4.94ms - +2.57ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -1% - +7% (-0.41ms - +2.51ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -4% - +2% (-0.16ms - +0.07ms)
    preact-local vs preact-master
  • todo: unsure 🔍 -1% - +2% (-0.79ms - +1.60ms)
    preact-local vs preact-master

usedJSHeapSize

  • 02_replace1k: unsure 🔍 -10% - +5% (-0.47ms - +0.26ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-master
  • 07_create10k: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -2% - +3% (-0.35ms - +0.45ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-master
  • todo: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-master

Results

02_replace1k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master86.04ms - 102.56ms-unsure 🔍
-15% - +8%
-14.99ms - +8.20ms
unsure 🔍
-6% - +23%
-4.46ms - +19.60ms
preact-local89.56ms - 105.84msunsure 🔍
-9% - +16%
-8.20ms - +14.99ms
-unsure 🔍
-2% - +27%
-0.99ms - +22.92ms
preact-hooks77.98ms - 95.48msunsure 🔍
-20% - +4%
-19.60ms - +4.46ms
unsure 🔍
-23% - +0%
-22.92ms - +0.99ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master4.35ms - 4.89ms-unsure 🔍
-6% - +10%
-0.26ms - +0.47ms
faster ✔
6% - 20%
0.27ms - 1.09ms
preact-local4.28ms - 4.76msunsure 🔍
-10% - +5%
-0.47ms - +0.26ms
-faster ✔
8% - 21%
0.40ms - 1.17ms
preact-hooks5.00ms - 5.61msslower ❌
5% - 24%
0.27ms - 1.09ms
slower ❌
8% - 27%
0.40ms - 1.17ms
-

run-warmup-0

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.96ms - 1.00ms-unsure 🔍
-2% - +3%
-0.02ms - +0.03ms
unsure 🔍
-1% - +4%
-0.01ms - +0.04ms
preact-local0.96ms - 0.99msunsure 🔍
-3% - +2%
-0.03ms - +0.02ms
-unsure 🔍
-2% - +3%
-0.02ms - +0.03ms
preact-hooks0.95ms - 0.99msunsure 🔍
-4% - +1%
-0.04ms - +0.01ms
unsure 🔍
-3% - +2%
-0.03ms - +0.02ms
-

run-warmup-1

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.59ms - 0.75ms-unsure 🔍
-32% - -0%
-0.27ms - +0.01ms
faster ✔
75% - 83%
1.99ms - 2.95ms
preact-local0.68ms - 0.92msunsure 🔍
-3% - +42%
-0.01ms - +0.27ms
-faster ✔
69% - 80%
1.85ms - 2.83ms
preact-hooks2.67ms - 3.61msslower ❌
280% - 461%
1.99ms - 2.95ms
slower ❌
210% - 378%
1.85ms - 2.83ms
-

run-warmup-2

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.40ms - 0.46ms-unsure 🔍
-3% - +14%
-0.01ms - +0.06ms
unsure 🔍
-3% - +15%
-0.01ms - +0.06ms
preact-local0.40ms - 0.43msunsure 🔍
-13% - +2%
-0.06ms - +0.01ms
-unsure 🔍
-5% - +6%
-0.02ms - +0.02ms
preact-hooks0.39ms - 0.43msunsure 🔍
-13% - +2%
-0.06ms - +0.01ms
unsure 🔍
-6% - +5%
-0.02ms - +0.02ms
-

run-warmup-3

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.40ms - 0.88ms-unsure 🔍
-48% - +58%
-0.29ms - +0.35ms
unsure 🔍
-9% - +99%
-0.04ms - +0.44ms
preact-local0.40ms - 0.82msunsure 🔍
-53% - +44%
-0.35ms - +0.29ms
-unsure 🔍
-10% - +87%
-0.04ms - +0.38ms
preact-hooks0.42ms - 0.47msunsure 🔍
-57% - -5%
-0.44ms - +0.04ms
unsure 🔍
-53% - -3%
-0.38ms - +0.04ms
-

run-warmup-4

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.30ms - 0.35ms-unsure 🔍
-3% - +18%
-0.01ms - +0.05ms
faster ✔
24% - 39%
0.11ms - 0.19ms
preact-local0.28ms - 0.32msunsure 🔍
-16% - +2%
-0.05ms - +0.01ms
-faster ✔
30% - 43%
0.13ms - 0.21ms
preact-hooks0.44ms - 0.51msslower ❌
30% - 62%
0.11ms - 0.19ms
slower ❌
42% - 72%
0.13ms - 0.21ms
-

run-final

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.32ms - 0.39ms-unsure 🔍
-25% - +1%
-0.11ms - +0.01ms
unsure 🔍
-16% - +7%
-0.06ms - +0.03ms
preact-local0.36ms - 0.45msunsure 🔍
-3% - +31%
-0.01ms - +0.11ms
-unsure 🔍
-5% - +22%
-0.02ms - +0.08ms
preact-hooks0.35ms - 0.39msunsure 🔍
-8% - +17%
-0.03ms - +0.06ms
unsure 🔍
-20% - +4%
-0.08ms - +0.02ms
-
03_update10th1k_x16

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master59.21ms - 62.04ms-unsure 🔍
-5% - +3%
-3.00ms - +1.92ms
unsure 🔍
-5% - +2%
-3.01ms - +0.95ms
preact-local59.15ms - 63.18msunsure 🔍
-3% - +5%
-1.92ms - +3.00ms
-unsure 🔍
-5% - +3%
-2.93ms - +1.96ms
preact-hooks60.27ms - 63.03msunsure 🔍
-2% - +5%
-0.95ms - +3.01ms
unsure 🔍
-3% - +5%
-1.96ms - +2.93ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master3.78ms - 3.79ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
10% - 10%
0.41ms - 0.41ms
preact-local3.78ms - 3.79msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
10% - 10%
0.41ms - 0.41ms
preact-hooks4.19ms - 4.20msslower ❌
11% - 11%
0.41ms - 0.41ms
slower ❌
11% - 11%
0.41ms - 0.41ms
-
07_create10k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1877.73ms - 1919.66ms-unsure 🔍
-3% - +1%
-56.67ms - +10.68ms
faster ✔
2% - 5%
36.33ms - 95.72ms
preact-local1895.34ms - 1948.05msunsure 🔍
-1% - +3%
-10.68ms - +56.67ms
-faster ✔
0% - 4%
9.31ms - 76.75ms
preact-hooks1943.68ms - 1985.76msslower ❌
2% - 5%
36.33ms - 95.72ms
slower ❌
0% - 4%
9.31ms - 76.75ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master25.84ms - 25.84ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
faster ✔
9% - 9%
2.55ms - 2.55ms
preact-local25.84ms - 25.84msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-faster ✔
9% - 9%
2.55ms - 2.55ms
preact-hooks28.39ms - 28.39msslower ❌
10% - 10%
2.55ms - 2.55ms
slower ❌
10% - 10%
2.55ms - 2.55ms
-
filter_list

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master22.74ms - 24.84ms-unsure 🔍
-0% - +9%
-0.11ms - +2.05ms
unsure 🔍
-4% - +5%
-1.03ms - +1.18ms
preact-local22.54ms - 23.09msunsure 🔍
-8% - +0%
-2.05ms - +0.11ms
-faster ✔
2% - 6%
0.44ms - 1.35ms
preact-hooks23.35ms - 24.07msunsure 🔍
-5% - +4%
-1.18ms - +1.03ms
slower ❌
2% - 6%
0.44ms - 1.35ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.93ms - 1.93ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
faster ✔
11% - 11%
0.24ms - 0.24ms
preact-local1.93ms - 1.93msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-faster ✔
11% - 11%
0.24ms - 0.24ms
preact-hooks2.16ms - 2.16msslower ❌
12% - 12%
0.24ms - 0.24ms
slower ❌
12% - 12%
0.24ms - 0.24ms
-
hydrate1k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master206.97ms - 212.30ms-unsure 🔍
-1% - +2%
-2.57ms - +4.94ms
unsure 🔍
-3% - +0%
-6.98ms - +0.22ms
preact-local205.81ms - 211.09msunsure 🔍
-2% - +1%
-4.94ms - +2.57ms
-faster ✔
0% - 4%
0.99ms - 8.15ms
preact-hooks210.60ms - 215.44msunsure 🔍
-0% - +3%
-0.22ms - +6.98ms
slower ❌
0% - 4%
0.99ms - 8.15ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master16.16ms - 16.67ms-unsure 🔍
-3% - +2%
-0.45ms - +0.35ms
slower ❌
0% - 6%
0.02ms - 0.88ms
preact-local16.16ms - 16.78msunsure 🔍
-2% - +3%
-0.35ms - +0.45ms
-slower ❌
0% - 6%
0.03ms - 0.97ms
preact-hooks15.62ms - 16.31msfaster ✔
0% - 5%
0.02ms - 0.88ms
faster ✔
0% - 6%
0.03ms - 0.97ms
-
many_updates

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master33.16ms - 35.02ms-unsure 🔍
-7% - +1%
-2.51ms - +0.41ms
faster ✔
4% - 11%
1.58ms - 4.27ms
preact-local34.01ms - 36.27msunsure 🔍
-1% - +7%
-0.41ms - +2.51ms
-faster ✔
1% - 9%
0.38ms - 3.37ms
preact-hooks36.04ms - 37.99msslower ❌
4% - 13%
1.58ms - 4.27ms
slower ❌
1% - 10%
0.38ms - 3.37ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master4.97ms - 4.97ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
faster ✔
8% - 8%
0.44ms - 0.45ms
preact-local4.97ms - 4.97msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-faster ✔
8% - 8%
0.44ms - 0.44ms
preact-hooks5.41ms - 5.41msslower ❌
9% - 9%
0.44ms - 0.45ms
slower ❌
9% - 9%
0.44ms - 0.44ms
-
text_update

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master3.50ms - 3.69ms-unsure 🔍
-2% - +5%
-0.07ms - +0.16ms
faster ✔
5% - 11%
0.19ms - 0.43ms
preact-local3.49ms - 3.61msunsure 🔍
-4% - +2%
-0.16ms - +0.07ms
-faster ✔
7% - 11%
0.26ms - 0.45ms
preact-hooks3.83ms - 3.98msslower ❌
5% - 12%
0.19ms - 0.43ms
slower ❌
7% - 13%
0.26ms - 0.45ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.14ms - 1.14ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
faster ✔
1% - 1%
0.02ms - 0.02ms
preact-local1.14ms - 1.14msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-faster ✔
1% - 1%
0.02ms - 0.02ms
preact-hooks1.16ms - 1.16msslower ❌
1% - 1%
0.02ms - 0.02ms
slower ❌
1% - 1%
0.02ms - 0.02ms
-
todo

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master68.04ms - 69.92ms-unsure 🔍
-2% - +1%
-1.60ms - +0.79ms
faster ✔
2% - 5%
1.42ms - 3.80ms
preact-local68.65ms - 70.13msunsure 🔍
-1% - +2%
-0.79ms - +1.60ms
-faster ✔
2% - 5%
1.17ms - 3.24ms
preact-hooks70.86ms - 72.32msslower ❌
2% - 6%
1.42ms - 3.80ms
slower ❌
2% - 5%
1.17ms - 3.24ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.43ms - 1.43ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
2% - 2%
0.03ms - 0.04ms
preact-local1.43ms - 1.43msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
2% - 3%
0.03ms - 0.04ms
preact-hooks1.47ms - 1.47msslower ❌
2% - 3%
0.03ms - 0.04ms
slower ❌
2% - 3%
0.03ms - 0.04ms
-

tachometer-reporter-action v2 for Benchmarks

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0007%) to 99.529% when pulling 0be145c on event-options into 9d4b2dc on master.

@github-actions
Copy link

Size Change: +327 B (0%)

Total Size: 53.4 kB

Filename Size Change
compat/dist/compat.js 3.82 kB +42 B (1%)
compat/dist/compat.module.js 3.76 kB +44 B (1%)
compat/dist/compat.umd.js 3.89 kB +42 B (1%)
dist/preact.js 4.09 kB +34 B (0%)
dist/preact.min.js 4.11 kB +33 B (0%)
dist/preact.min.module.js 4.11 kB +33 B (0%)
dist/preact.min.umd.js 4.14 kB +33 B (0%)
dist/preact.module.js 4.1 kB +34 B (0%)
dist/preact.umd.js 4.15 kB +32 B (0%)
ℹ️ View Unchanged
Filename Size Change
debug/dist/debug.js 3.01 kB 0 B
debug/dist/debug.module.js 3.01 kB 0 B
debug/dist/debug.umd.js 3.09 kB 0 B
devtools/dist/devtools.js 231 B 0 B
devtools/dist/devtools.module.js 240 B 0 B
devtools/dist/devtools.umd.js 314 B 0 B
hooks/dist/hooks.js 1.55 kB 0 B
hooks/dist/hooks.module.js 1.59 kB 0 B
hooks/dist/hooks.umd.js 1.64 kB 0 B
jsx-runtime/dist/jsxRuntime.js 358 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 324 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 439 B 0 B
test-utils/dist/testUtils.js 442 B 0 B
test-utils/dist/testUtils.module.js 444 B 0 B
test-utils/dist/testUtils.umd.js 526 B 0 B

compressed-size-action

@@ -90,12 +90,17 @@ export function setProperty(dom, name, value, oldValue, isSvg) {
else name = name.slice(2);

if (!dom._listeners) dom._listeners = {};
if (!useCapture && Array.isArray(value)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens here when the user changes from passive to active? We would need to re-register the event-handler which might be unexpected that we aren't doing that. It did make me wonder whether the -capture would be a good fit for the -passive as well. The only other options are once and signal which I am not sure would fit here reliably....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoviDeCroock According to MDN only the capture option is checked for matching event listeners. See: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener#matching_event_listeners_for_removal

@marvinhagemeister marvinhagemeister marked this pull request as draft October 17, 2022 16:23
@marvinhagemeister
Copy link
Member Author

Marking as a draft, because browsers seems to turn scroll events into passive automatically in all browsers. Seems like the chrome DevTools warning is outdated? The passive option was the only reason going for implementing it. Leaving it here in case of future considerations.

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.

Support passive event listeners
4 participants