Skip to content

Limitation: event.preventDefault() #2

@andywer

Description

@andywer

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 😊

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions