Skip to content

Commit f717226

Browse files
committed
Only splice from internal arrays when item actually exists.
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
1 parent b9cdc41 commit f717226

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/data.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,11 @@ Data.prototype = {
122122
},
123123
discard: function( owner ) {
124124
var index = this.owners.indexOf( owner );
125-
this.owners.splice( index, 1 );
126-
this.cache.splice( index, 1 );
125+
126+
if ( index >= 0 ) {
127+
this.owners.splice( index, 1 );
128+
this.cache.splice( index, 1 );
129+
}
127130
return this;
128131
}
129132
};

0 commit comments

Comments
 (0)