AUR0769
Error Message
AUR0769: Failed to initialize the platform object. The host element's ownerDocument does not have a defaultView, did you create the host from a DOMParser and forget to call adoptNode()?
Description
Aurelia creates its browser platform from host.ownerDocument.defaultView. Documents created by DOMParser and document.implementation.createHTMLDocument() are detached document contexts, so their defaultView is null.
Solution
Use a host owned by the active browser document. Adopt parsed content before configuring the application:
const parsed = new DOMParser().parseFromString(
'<main id="app"></main>',
'text/html',
);
const host = document.adoptNode(parsed.querySelector<HTMLElement>('#app')!);
document.body.append(host);
const aurelia = new Aurelia().app({ host, component: MyApp });
await aurelia.start();To copy the parsed subtree instead of moving it, replace the adoptNode() call with:
A DOM-based test runner or rendering host can register its compatible IPlatform implementation in the application container.
Last updated
Was this helpful?