Clean up dynamically inserted assets when template is unmounted #274

This commit is contained in:
garronej
2023-04-19 03:20:22 +02:00
parent 2bf3296c0f
commit cf1e595ba2
3 changed files with 45 additions and 22 deletions

View File

@ -12,7 +12,7 @@ export function headInsert(
type: "javascript";
src: string;
}
) {
): { remove: () => void; prLoaded: Promise<void> } {
const htmlElement = document.createElement(
(() => {
switch (params.type) {
@ -66,5 +66,8 @@ export function headInsert(
})()
](htmlElement);
return dLoaded.pr;
return {
"prLoaded": dLoaded.pr,
"remove": () => htmlElement.remove()
};
}