From e9d598f5aa62b91620a94b863a1a9cb081d01e3b Mon Sep 17 00:00:00 2001 From: Olaf Braun Date: Fri, 2 Aug 2024 17:10:31 +0200 Subject: [PATCH] Switch map and filter on the array --- ts/WoltLabSuite/Core/Form/Builder/Field/Select.ts | 10 ++-------- .../js/WoltLabSuite/Core/Form/Builder/Field/Select.js | 9 ++------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/ts/WoltLabSuite/Core/Form/Builder/Field/Select.ts b/ts/WoltLabSuite/Core/Form/Builder/Field/Select.ts index 4222d3eeb9..45d69255ac 100644 --- a/ts/WoltLabSuite/Core/Form/Builder/Field/Select.ts +++ b/ts/WoltLabSuite/Core/Form/Builder/Field/Select.ts @@ -13,14 +13,8 @@ import { FormBuilderData } from "../Data"; export default class Select extends Field { protected _getData(): FormBuilderData { const values = Array.from(this._field!.querySelectorAll(`option`)) - .map((input) => { - if (input.selected) { - return input.value; - } - - return null; - }) - .filter((v) => v !== null) as string[]; + .filter((input) => input.selected) + .map((input) => input.value); return { [this._fieldId]: values, diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Select.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Select.js index 1f3dbcf9de..540b34b4e6 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Select.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Select.js @@ -13,13 +13,8 @@ define(["require", "exports", "tslib", "./Field"], function (require, exports, t class Select extends Field_1.default { _getData() { const values = Array.from(this._field.querySelectorAll(`option`)) - .map((input) => { - if (input.selected) { - return input.value; - } - return null; - }) - .filter((v) => v !== null); + .filter((input) => input.selected) + .map((input) => input.value); return { [this._fieldId]: values, }; -- 2.20.1