From: Marcel Werk Date: Tue, 17 Dec 2024 13:29:21 +0000 (+0100) Subject: Fix issue with creating table row elements X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1412aa836373670406503a29e86260e498eb63e5;p=GitHub%2FWoltLab%2FWCF.git Fix issue with creating table row elements --- diff --git a/ts/WoltLabSuite/Core/Dom/Util.ts b/ts/WoltLabSuite/Core/Dom/Util.ts index a346947100..8a4ec354b7 100644 --- a/ts/WoltLabSuite/Core/Dom/Util.ts +++ b/ts/WoltLabSuite/Core/Dom/Util.ts @@ -43,13 +43,11 @@ const DomUtil = { * Returns a DocumentFragment containing the provided HTML string as DOM nodes. */ createFragmentFromHtml(html: string): DocumentFragment { - const tmp = document.createElement("div"); - DomUtil.setInnerHtml(tmp, html); + const template = document.createElement("template"); + DomUtil.setInnerHtml(template, html); const fragment = document.createDocumentFragment(); - while (tmp.childNodes.length) { - fragment.appendChild(tmp.childNodes[0]); - } + fragment.append(template.content.cloneNode(true)); return fragment; }, diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Dom/Util.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Dom/Util.js index c5a472f2b5..2903284b3e 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Dom/Util.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Dom/Util.js @@ -38,12 +38,10 @@ define(["require", "exports", "tslib", "../StringUtil"], function (require, expo * Returns a DocumentFragment containing the provided HTML string as DOM nodes. */ createFragmentFromHtml(html) { - const tmp = document.createElement("div"); - DomUtil.setInnerHtml(tmp, html); + const template = document.createElement("template"); + DomUtil.setInnerHtml(template, html); const fragment = document.createDocumentFragment(); - while (tmp.childNodes.length) { - fragment.appendChild(tmp.childNodes[0]); - } + fragment.append(template.content.cloneNode(true)); return fragment; }, /**