From ef7f3944efb3a6ce22106da21f1b6b862e694534 Mon Sep 17 00:00:00 2001 From: paulnotley <78230102+paulnotley@users.noreply.github.com> Date: Wed, 13 Jul 2022 08:29:41 -0700 Subject: [PATCH] Avoid for...in to iterate through array Using for...in to iterate through the CSL.FORMAT_KEY_SEQUENCE array breaks things if the Array.prototype has been modified to have additional methods / attrs Also removed unnecessary "if (true) { ..." conditional --- src/util_processor.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/util_processor.js b/src/util_processor.js index 7c2ca0012..3307fc53c 100644 --- a/src/util_processor.js +++ b/src/util_processor.js @@ -102,13 +102,11 @@ CSL.setDecorations = function (state, attributes) { var ret, key, pos; // This applies a fixed processing sequence ret = []; - for (pos in CSL.FORMAT_KEY_SEQUENCE) { - if (true) { - var key = CSL.FORMAT_KEY_SEQUENCE[pos]; - if (attributes[key]) { - ret.push([key, attributes[key]]); - delete attributes[key]; - } + for (pos = 0; pos < CSL.FORMAT_KEY_SEQUENCE.length; pos++) { + var key = CSL.FORMAT_KEY_SEQUENCE[pos]; + if (attributes[key]) { + ret.push([key, attributes[key]]); + delete attributes[key]; } } return ret;