* add a default head method through eval * remove the old document trait * implement document for each platform * pull out document into a dedicated crate to cut down on shared dependencies --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
20 lines
490 B
TypeScript
20 lines
490 B
TypeScript
// Helper functions for working with the document head
|
|
|
|
function createElementInHead(
|
|
tag: string,
|
|
attributes: [string, string][],
|
|
children: string | null
|
|
): void {
|
|
const element = document.createElement(tag);
|
|
for (const [key, value] of attributes) {
|
|
element.setAttribute(key, value);
|
|
}
|
|
if (children) {
|
|
element.appendChild(document.createTextNode(children));
|
|
}
|
|
document.head.appendChild(element);
|
|
}
|
|
|
|
// @ts-ignore
|
|
window.createElementInHead = createElementInHead;
|