MCPcopy Create free account
hub / github.com/UI5/webcomponents / createLinkInHead

Function createLinkInHead

packages/base/src/util/createLinkInHead.ts:6–23  ·  view source on GitHub ↗
(href: string, attributes?: Record<string, string>)

Source from the content-addressed store, hash-verified

4 * @param attributes - optional attributes to add to the tag
5 */
6const createLinkInHead = (href: string, attributes?: Record<string, string>) => {
7 const link = document.createElement("link");
8 link.type = "text/css";
9 link.rel = "stylesheet";
10
11 if (attributes) {
12 Object.entries(attributes).forEach(pair => link.setAttribute(...pair));
13 }
14
15 link.href = href;
16
17 document.head.appendChild(link);
18
19 return new Promise<Event>(resolve => {
20 link.addEventListener("load", resolve);
21 link.addEventListener("error", resolve); // intended
22 });
23};
24
25export default createLinkInHead;

Callers 1

Calls 1

appendChildMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…