-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Hi there!
I thought about outsourcing rendering of React components into web workers a lot last year, and there was one issue I couldn't really solve. It might help you to know about this limitation when accessing the DOM from within web workers :)
event.preventDefault()
If the click handler resides in the web worker, then it will be invoked asynchronously. Unfortunately, due to its very nature, event.preventDefault() and event.stopPropagation() have to be called synchronously in order to work.
event.stopPropagation() might be worked around by using event delegation, but I don't see a good solution for event.preventDefault(). You could only highlight the DOM node / the event listener to always prevent default behavior, so the call happens immediately in the main thread. But a conditional preventDefault() is then not possible.
Hope you can make some use of that!
Btw, keep me posted if you have a good idea how to approach this issue 😊