From 0bef366553ac5120ac9e2f6077421d9d8fa4f1ee Mon Sep 17 00:00:00 2001 From: fraxken Date: Thu, 21 Aug 2025 15:58:05 +0200 Subject: [PATCH] refactor(documentation-ui): remove container HTMLElement dependency --- public/components/wiki/wiki.js | 22 +++++++++++++++++----- workspaces/documentation-ui/index.js | 11 +++-------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/public/components/wiki/wiki.js b/public/components/wiki/wiki.js index bfc2efef..a6b54c5e 100644 --- a/public/components/wiki/wiki.js +++ b/public/components/wiki/wiki.js @@ -6,13 +6,25 @@ import { PackageInfo } from "../package/package.js"; export class Wiki { constructor() { - this.documentationRootElement = document.querySelector("#documentation-root-element"); - this.documentationRenderContainer = this.documentationRootElement.querySelector(".documentation-render-container"); - this.openButton = this.documentationRootElement.querySelector(".open-button"); + this.documentationRootElement = document.querySelector( + "#documentation-root-element" + ); + this.openButton = this.documentationRootElement.querySelector( + ".open-button" + ); + + const { container, header, navigation } = documentationUI.render( + { preCacheAllFlags: true } + ); - const { header, navigation } = documentationUI.render( - this.documentationRenderContainer, { preCacheAllFlags: true } + const documentationRenderContainer = this.documentationRootElement.querySelector( + ".documentation-render-container" ); + for (const node of documentationRenderContainer.childNodes) { + node.remove(); + } + documentationRenderContainer.appendChild(container); + /** @type {documentationUI.Header} */ this.header = header; /** @type {Record} */ diff --git a/workspaces/documentation-ui/index.js b/workspaces/documentation-ui/index.js index e25ec969..9607e5cc 100644 --- a/workspaces/documentation-ui/index.js +++ b/workspaces/documentation-ui/index.js @@ -47,11 +47,10 @@ const kHeaderMenus = Object.entries(kWikiMenus) /** * @description Render the documentation module in a given container - * @param {!HTMLElement} rootElement * @param {object} [options] * @param {boolean} [options.prefetch=false] */ -export function render(rootElement, options = {}) { +export function render(options = {}) { const { prefetch = false } = options; /** @type {Record} */ @@ -83,17 +82,13 @@ export function render(rootElement, options = {}) { } const header = new Header(kHeaderMenus, { defaultName: "flags" }); - const mainContainer = utils.createDOMElement("div", { + const container = utils.createDOMElement("div", { className: "documentation--main", childs: [header.dom, ...containers] }); - for (const node of rootElement.childNodes) { - node.remove(); - } - rootElement.appendChild(mainContainer); - return { + container, header, navigation };