Fix issue with linked list remove (#7065)

* Added failing linked-list test for #7059

* Fixed linked-list remove bug #7059
This commit is contained in:
btheado
2022-11-26 15:05:10 +00:00
committed by GitHub
parent 32a033bb50
commit bea1a6b14f
2 changed files with 18 additions and 7 deletions
+3 -7
View File
@@ -136,13 +136,9 @@ function _removeOne(list,value) {
// we need to know if the FIRST value is the last in the list, not the last.
if(next !== undefined) {
if(typeof list.prev[next] === "object") {
if(prev === undefined) {
// Must have been first, and 'i' would be 0.
list.prev[next].shift();
} else {
var i = list.prev[next].indexOf(value);
list.prev[next][i] = prev;
}
// Nothing special needed for first since list.prev[next][0] will be 'undefined'
var i = list.prev[next].indexOf(value);
list.prev[next][i] = prev;
} else {
list.prev[next] = prev;
}