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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Do not merge] Attach all local listeners as captured events #11832

Closed
wants to merge 3 commits into from

Conversation

nhunzaker
Copy link
Contributor

I noticed in #9333 that events that don't bubble are still captureable (scroll, wheel). So that got me curious about all of the other events we attach locally for that very reason.

I've used the following test page to confirm this:
https://codepen.io/nhunzaker/pen/babXLO

https://codepen.io/anon/pen/YYKoJW?editors=1010

What I need help with

Is this even a good idea? 馃槢. Are there any design issues with using captured events this way?

Right now, this PR only moves the local attachment over, as needed, to ReactBrowserEventEmitter. There is a more aggressive change: what if we attached all events as capture? Period. Given bubbling is synthetic anyway, what could go wrong if we attached everything using capture? Then we wouldn't really need to distinguish local listeners other the handful we have for focus and scrolling.

Things that still need confirmation:

  • iframe: onload
  • object: onload
  • video,audio: abort, canplay, canplaythrough, durationchange, emptied, encrypted, ended, error, loadeddata, loadedmetadata, loadstart, pause, play, playing, progress, ratechange, seeked, seeking, stalled, suspend, timeupdate, volumechange, waiting
  • source: error
  • img (test): onload, onerror
  • image (svg): onload, onerror
  • form: reset, submit
  • details: toggle
  • input: invalid
  • select: invalid
  • textarea: invalid

So basically media events are left. For all the others, I've tested:

It looks like captured events pick up events that do not bubble. This
means we might not need to attach them eagerly. At least, this works
for the load/error event on image elements and the unit test suite. It
still needs manual verification.
@nhunzaker
Copy link
Contributor Author

I learned what I needed from this. Closing.

@nhunzaker nhunzaker closed this May 28, 2018
@nhunzaker nhunzaker deleted the nh-load-events branch June 4, 2018 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants