Open insipidish opened 8 years ago
Ah yeah that's a good point. This uses the browser's built-in DOM parser, which isn't available under node. Should be possible to detect node and require() in a simple parser lib though! Will need to update the code :)
Preact WMR injects a NodeJS DOMParser
for static SSR (aka "prerender"):
globalThis.DOMParser = new (require('jsdom').JSDOM)('').window.DOMParser;
(PR context: https://github.com/preactjs/wmr/pull/497/files )
This way, this never fails:
...and this iframe
-based fallback never gets called in the html
case:
Related PRs:
https://github.com/developit/preact-markup/pull/24
https://github.com/developit/preact-markup/pull/22
Hi
I am trying to use the Markup component while rendering server side with preact-render-to-string.
I get the following error: 'ReferenceError: document is not defined'
Could you suggest a work around?