From 5a8c1c7058dfb1aa01735ef1d204aa9babbb4aa4 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 15 Dec 2018 09:33:33 +0100 Subject: [PATCH] =?utf8?q?Replace=20`for=20(=E2=80=A6=20of=20=E2=80=A6)`?= =?utf8?q?=20JavaScript=20loops?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit See #2772 --- .../Core/Form/Builder/Field/Dependency/Manager.js | 10 ++++------ .../Field/Devtools/Project/Instructions.js | 15 +++++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager.js index 4ecfbf2cf9..7746d3e2b8 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager.js @@ -73,12 +73,11 @@ define(['Dictionary', 'Dom/ChangeListener', 'EventHandler', 'List', 'Dom/Travers // also hide tab menu entry if (node.classList.contains('tabMenuContent')) { - for (var tabLink of elBySelAll('li', DomTraverse.prevByClass(node, 'tabMenu'))) { + elBySelAll('li', DomTraverse.prevByClass(node, 'tabMenu'), function(tabLink) { if (elData(tabLink, 'name') === elData(node, 'name')) { elHide(tabLink); - break; } - } + }); } elBySelAll('[max], [maxlength], [min], [required]', node, function(validatedField) { @@ -123,12 +122,11 @@ define(['Dictionary', 'Dom/ChangeListener', 'EventHandler', 'List', 'Dom/Travers // also show tab menu entry if (node.classList.contains('tabMenuContent')) { - for (var tabLink of elBySelAll('li', DomTraverse.prevByClass(node, 'tabMenu'))) { + elBySelAll('li', DomTraverse.prevByClass(node, 'tabMenu'), function(tabLink) { if (elData(tabLink, 'name') === elData(node, 'name')) { elShow(tabLink); - break; } - } + }); } elBySelAll('input, select', node, function(validatedField) { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Devtools/Project/Instructions.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Devtools/Project/Instructions.js index fc031fb407..ef0f484723 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Devtools/Project/Instructions.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Devtools/Project/Instructions.js @@ -108,7 +108,9 @@ define([ var hasInstallInstructions = false; - for (var instructions of existingInstructions) { + for (var index in existingInstructions) { + var instructions = existingInstructions[index]; + if (instructions.type === 'install') { hasInstallInstructions = true; break; @@ -191,9 +193,10 @@ define([ '
' + ' ' + Language.get('wcf.acp.devtools.project.instruction.instruction', instructionData); - for (var errorMessage of instructionData.errors || []) { - content += '' + - ' ' + errorMessage + ''; + if (instructionData.errors) { + for (var index in instructionData.errors) { + content += '' + instructionData.errors[index] + ''; + } } content += '' + @@ -297,8 +300,8 @@ define([ elById(this._formFieldId + '_instructions' + instructionsId + '_addButton').addEventListener('click', this._addInstruction.bind(this)); if (instructionsData.instructions) { - for (var instruction of instructionsData.instructions) { - this._addInstructionByData(instructionsId, instruction); + for (var index in instructionsData.instructions) { + this._addInstructionByData(instructionsId, instructionsData.instructions[index]); } } }, -- 2.20.1