Skip to content

Commit a38ad2d

Browse files
committed
Merge pull request phaserjs#85 from onedayitwillmake/dev
Fixed accidentally overwroting remove function with a prepend function
2 parents 9b4b267 + f593afd commit a38ad2d

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

src/core/LinkedList.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,14 @@ Phaser.LinkedList.prototype = {
8787
* @param {object} child - Description.
8888
*/
8989
remove: function (child) {
90-
if( this.first ) {
91-
child.next = this.last.next;
92-
child.prev = this.last;
93-
if( this.last.next ) {
94-
this.last.next.prev = child;
95-
}
96-
this.last.next = child;
97-
this.last = this.last.next;
98-
} else {
99-
this.first = this.last = child;
100-
}
90+
if( child == this.first ) this.first = this.first.next; // It was 'first', make 'first' point to first.next
91+
else if ( child == this.last ) this.last = this.last.prev; // It was 'last', make 'last' point to last.prev
92+
93+
if( child.prev ) child.prev.next = child.next; // make child.prev.next point to childs.next instead of child
94+
if( child.next ) child.next.prev = child.prev; // make child.next.prev point to child.prev instead of child
95+
child.next = child.prev = null;
96+
97+
if( this.first == null ) this.last = null;
10198

10299
this.total--;
103100
},

0 commit comments

Comments
 (0)