Reindex 'key_indicies' after item delete

The "keys.splice(i, 1)" removes one item at the specified position
from an array. Thus hashes which are stored at "that._key_indicies"
are no longer valid and should be reindexed.

Fixes: https://pagure.io/freeipa/issue/7678
Reviewed-By: Serhii Tsymbaliuk <stsymbal@redhat.com>
This commit is contained in:
Stanislav Levin 2018-08-22 22:47:04 +03:00 committed by Serhii Tsymbaliuk
parent c3f23da49d
commit 0dcce426a4

View File

@ -112,6 +112,11 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function(map) {
that.keys.splice(i, 1);
that.values.splice(i, 1);
delete that._key_indicies[key];
// reindex
for (var j=i; j<that.keys.length; j++) {
that._key_indicies[that.keys[j]]=j;
}
that.length = that.keys.length;
return value;
};