From 1412aa836373670406503a29e86260e498eb63e5 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 17 Dec 2024 14:29:21 +0100 Subject: [PATCH] Fix issue with creating table row elements --- ts/WoltLabSuite/Core/Dom/Util.ts | 8 +++----- wcfsetup/install/files/js/WoltLabSuite/Core/Dom/Util.js | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) 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; }, /** -- 2.20.1