this.#title.textContent = title;
- if (this.#dialog.parentElement === null) {
- if (dialogContainer.parentElement === null) {
- document.getElementById("content")!.append(dialogContainer);
- }
+ if (dialogContainer.parentElement === null) {
+ document.getElementById("content")!.append(dialogContainer);
+ }
+ if (this.parentElement !== dialogContainer) {
dialogContainer.append(this);
}
releasePageOverlayContainer(this.#dialog);
scrollEnable();
+
+ // Remove the dialog from the DOM, preventing it from
+ // causing any collisions caused by elements with IDs
+ // contained inside it. Will also cause the DOM element
+ // to be garbage collected when there are no more
+ // references to it.
+ this.remove();
}
get dialog(): HTMLDialogElement {
throw new Error("Cannot open the modal dialog without a title.");
}
this.#title.textContent = title;
- if (this.#dialog.parentElement === null) {
- if (dialogContainer.parentElement === null) {
- document.getElementById("content").append(dialogContainer);
- }
+ if (dialogContainer.parentElement === null) {
+ document.getElementById("content").append(dialogContainer);
+ }
+ if (this.parentElement !== dialogContainer) {
dialogContainer.append(this);
}
this.#dialog.showModal();
this.dispatchEvent(event);
(0, PageOverlay_1.releasePageOverlayContainer)(this.#dialog);
(0, Screen_1.scrollEnable)();
+ // Remove the dialog from the DOM, preventing it from
+ // causing any collisions caused by elements with IDs
+ // contained inside it. Will also cause the DOM element
+ // to be garbage collected when there are no more
+ // references to it.
+ this.remove();
}
get dialog() {
return this.#dialog;