html-react-parser icon indicating copy to clipboard operation
html-react-parser copied to clipboard

Usage in web worker

Open jlarmstrongiv opened this issue 1 year ago • 11 comments

Expected Behavior

Render html to react elements

Actual Behavior

Uncaught (in promise) Error: This browser does not support `document.implementation.createHTMLDocument`
    at parseFromDocument (html-react-parser.js?v=474f97b5:38:13)
    at domparser (html-react-parser.js?v=474f97b5:109:25)
    at HTMLDOMParser (html-react-parser.js?v=474f97b5:277:65)
    at HTMLReactParser2 (html-react-parser.js?v=474f97b5:1778:72)

Steps to Reproduce

Try using html-react-parser in a web worker

Reproducible Demo

I will create a demo if there is interest in fixing this bug.

I believe it’s due to the more limited environment of web workers, which does not have access to window or document objects.

A similar issue for Vercel Edge Functions was closed as wontfix https://github.com/remarkablemark/html-react-parser/issues/736

Regardless, I’m open and looking for workarounds to make html-react-parser work in a web worker

Environment

  • Version: 5.1.10
  • Platform: Web Worker
  • Browser: Chrome
  • OS: MacOS

Keywords

Web worker

jlarmstrongiv avatar Apr 17 '24 17:04 jlarmstrongiv