-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
Onunload does not get called when a component gets reloaded or updated.
This is crucial as connections or event subscribers can't be closed properly.
Quick fixed it.
Don't know if this is properly implemented but after testing it a bit, I'm confident it works in any case.
Component.prototype.reload = async function () {
await this.unload(); <-------------- !!!
await this.onload();
if (this.child) {
await this.child.reload();
}
await this.update();
}
Component.prototype['addToElement'] = function addToElement(item, element: Node) {
if (item instanceof Node) {
element.appendChild(item);
} else if (Array.isArray(item)) {
for (let child of item) {
this.addToElement(child, element);
}
} else if (item instanceof Component) {
const placeholder = item.renderLoader();
element.appendChild(placeholder);
item.parent = this;
(async () => {
await item.onunload(); <-------------- !!!
await item.onload();
const child = item.render();
item.rootNode = child;
element.replaceChild(child, placeholder);
})();
} else if (item !== false && item !== undefined && item !== null) {
element.appendChild(document.createTextNode(item));
}
}
Component.prototype.host = async function host(parent: Node) {
await this.onunload(); <-------------- !!!
await this.onload();
const root = this.render();
this.rootNode = root;
this.parent = null;
parent.appendChild(root);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working