importDefinitions

Loads an HTML file and defines every <custom-element> in it. The JavaScript form of <import-element>.

importDefinitions(url: string): Promise<void>
import { importDefinitions } from "https://cdn.jsdelivr.net/npm/@realmorg/realm@alpha/dist/index.js";

await importDefinitions(new URL("components/chart.html", document.baseURI).href);
document.body.append(document.createElement("sales-chart"));

Parameters

Parameter Type Meaning
url string Absolute URL of the file. Relative URLs inside the file resolve against it

Returns

A promise that resolves when every definition in the file is defined. It rejects with an error whose message is Could not import URL (HTTP status) and which carries url and status (0 for network errors).

Behaviour

Edit this page on GitHub · View as Markdown