From 98a448377192ff9d3007019e55d46deb0d409403 Mon Sep 17 00:00:00 2001 From: Tim Aldinger Date: Mon, 12 Oct 2026 14:14:42 +0200 Subject: [PATCH] appendChild mit append ersetzt --- src/main/resources/static/js/models/ShoppingItem.js | 7 ++----- .../resources/static/js/pages/index/frontend/indexUI.js | 4 +--- .../resources/static/js/pages/list/frontend/categoryUI.js | 8 +++----- .../resources/static/js/pages/list/frontend/itemUI.js | 7 ++----- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/main/resources/static/js/models/ShoppingItem.js b/src/main/resources/static/js/models/ShoppingItem.js index 3946153..387c29c 100644 --- a/src/main/resources/static/js/models/ShoppingItem.js +++ b/src/main/resources/static/js/models/ShoppingItem.js @@ -42,12 +42,9 @@ export class ShoppingItem { deleteItemButton.classList.add("item__deleteButton"); deleteItemButton.textContent = "Löschen"; - span.appendChild(spanName); - span.appendChild(spanAmount); + span.append(spanName, spanAmount); - li.appendChild(checkboxDone) - li.appendChild(span); - li.appendChild(deleteItemButton); + li.append(checkboxDone, span, deleteItemButton); return li; } diff --git a/src/main/resources/static/js/pages/index/frontend/indexUI.js b/src/main/resources/static/js/pages/index/frontend/indexUI.js index 6f4e900..678996c 100644 --- a/src/main/resources/static/js/pages/index/frontend/indexUI.js +++ b/src/main/resources/static/js/pages/index/frontend/indexUI.js @@ -32,9 +32,7 @@ export function createEditListForm(textElement) { saveButton.classList.add("editForm__saveButton"); abortButton.classList.add("editForm__abortButton"); - editForm.appendChild(inputName); - editForm.appendChild(saveButton); - editForm.appendChild(abortButton); + editForm.append(inputName, saveButton, abortButton); return editForm; } diff --git a/src/main/resources/static/js/pages/list/frontend/categoryUI.js b/src/main/resources/static/js/pages/list/frontend/categoryUI.js index 287d4f2..39903af 100644 --- a/src/main/resources/static/js/pages/list/frontend/categoryUI.js +++ b/src/main/resources/static/js/pages/list/frontend/categoryUI.js @@ -5,14 +5,14 @@ export function addCategory(categoryAsJSON) { const list = document.querySelector(".displayedList"); const category = ShoppingCategory.fromJSON(categoryAsJSON); - list.appendChild(category.render()); //fügt Kategorie der Liste hinzu + list.append(category.render()); //fügt Kategorie der Liste hinzu const categorySelect = document.querySelector(".addItemForm__categorySelect"); const newCategoryOption = document.createElement("option"); newCategoryOption.setAttribute("value", category.categoryID); newCategoryOption.textContent = category.categoryName; - categorySelect.appendChild(newCategoryOption); + categorySelect.append(newCategoryOption); } export function deleteCategory(deleteAllItems, categoryID) { @@ -39,9 +39,7 @@ export function createEditCategoryForm(textElement) { abortButton.textContent = "Abbrechen"; saveButton.textContent = "Speichern"; - editForm.appendChild(inputName); - editForm.appendChild(saveButton); - editForm.appendChild(abortButton); + editForm.append(inputName, saveButton, abortButton); return editForm; } diff --git a/src/main/resources/static/js/pages/list/frontend/itemUI.js b/src/main/resources/static/js/pages/list/frontend/itemUI.js index 2d20088..275861e 100644 --- a/src/main/resources/static/js/pages/list/frontend/itemUI.js +++ b/src/main/resources/static/js/pages/list/frontend/itemUI.js @@ -10,7 +10,7 @@ export function addItem(itemAsJSON) { const item = ShoppingItem.fromJSON(itemAsJSON); - list.appendChild(item.render()); + list.append(item.render()); } export function createEditItemForm(textElement) { @@ -33,10 +33,7 @@ export function createEditItemForm(textElement) { saveButton.textContent = "Speichern"; - editForm.appendChild(inputName); - editForm.appendChild(inputAmount); - editForm.appendChild(saveButton); - editForm.appendChild(abortButton); + editForm.append(inputName, inputAmount, saveButton, abortButton); return editForm; }