summaryrefslogtreecommitdiff
path: root/dev/build.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-12-18 15:46:39 -0500
committerGitHub <noreply@github.com>2020-12-18 15:46:39 -0500
commitfd91a5b383addb1b420fba0450a89ceb50cdd3e8 (patch)
treef2864070ad6a45d5e7b3f0adceab2db0e6022c37 /dev/build.js
parentdf7834a8805aa813fe44bc20ae6d24f6bbe70dde (diff)
Fix after index not being incremented (#1124)
Diffstat (limited to 'dev/build.js')
-rw-r--r--dev/build.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/dev/build.js b/dev/build.js
index 72dce283..3d0a427b 100644
--- a/dev/build.js
+++ b/dev/build.js
@@ -87,9 +87,16 @@ function applyModifications(manifest, modifications) {
const key = path2[path2.length - 1];
let {index} = modification;
- if (typeof index !== 'number') { index = -1; }
- if (typeof before === 'string') { index = getObjectKeyIndex(object, before); }
- if (typeof after === 'string') { index = getObjectKeyIndex(object, after); }
+ if (typeof index !== 'number') {
+ index = -1;
+ }
+ if (typeof before === 'string') {
+ index = getObjectKeyIndex(object, before);
+ }
+ if (typeof after === 'string') {
+ index = getObjectKeyIndex(object, after);
+ if (index >= 0) { ++index; }
+ }
setObjectKeyAtIndex(object, key, value, index);
}
@@ -139,9 +146,17 @@ function applyModifications(manifest, modifications) {
const oldObjectIsNewObject = arraysAreSame(path2, newPath, -1);
const value = oldObject[oldKey];
- let index = (oldObjectIsNewObject && action !== 'copy') ? getObjectKeyIndex(oldObject, oldKey) : -1;
- if (typeof before === 'string') { index = getObjectKeyIndex(newObject, before); }
- if (typeof after === 'string') { index = getObjectKeyIndex(newObject, after); }
+ let {index} = modification;
+ if (typeof index !== 'number' || index < 0) {
+ index = (oldObjectIsNewObject && action !== 'copy') ? getObjectKeyIndex(oldObject, oldKey) : -1;
+ }
+ if (typeof before === 'string') {
+ index = getObjectKeyIndex(newObject, before);
+ }
+ if (typeof after === 'string') {
+ index = getObjectKeyIndex(newObject, after);
+ if (index >= 0) { ++index; }
+ }
setObjectKeyAtIndex(newObject, newKey, value, index);
if (action !== 'copy' && (!oldObjectIsNewObject || oldKey !== newKey)) {