aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)) {