Fix after index not being incremented (#1124)
This commit is contained in:
parent
df7834a880
commit
fd91a5b383
27
dev/build.js
27
dev/build.js
@ -87,9 +87,16 @@ function applyModifications(manifest, modifications) {
|
|||||||
const key = path2[path2.length - 1];
|
const key = path2[path2.length - 1];
|
||||||
|
|
||||||
let {index} = modification;
|
let {index} = modification;
|
||||||
if (typeof index !== 'number') { index = -1; }
|
if (typeof index !== 'number') {
|
||||||
if (typeof before === 'string') { index = getObjectKeyIndex(object, before); }
|
index = -1;
|
||||||
if (typeof after === 'string') { index = getObjectKeyIndex(object, after); }
|
}
|
||||||
|
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);
|
setObjectKeyAtIndex(object, key, value, index);
|
||||||
}
|
}
|
||||||
@ -139,9 +146,17 @@ function applyModifications(manifest, modifications) {
|
|||||||
const oldObjectIsNewObject = arraysAreSame(path2, newPath, -1);
|
const oldObjectIsNewObject = arraysAreSame(path2, newPath, -1);
|
||||||
const value = oldObject[oldKey];
|
const value = oldObject[oldKey];
|
||||||
|
|
||||||
let index = (oldObjectIsNewObject && action !== 'copy') ? getObjectKeyIndex(oldObject, oldKey) : -1;
|
let {index} = modification;
|
||||||
if (typeof before === 'string') { index = getObjectKeyIndex(newObject, before); }
|
if (typeof index !== 'number' || index < 0) {
|
||||||
if (typeof after === 'string') { index = getObjectKeyIndex(newObject, after); }
|
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);
|
setObjectKeyAtIndex(newObject, newKey, value, index);
|
||||||
if (action !== 'copy' && (!oldObjectIsNewObject || oldKey !== newKey)) {
|
if (action !== 'copy' && (!oldObjectIsNewObject || oldKey !== newKey)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user