]> source.dussan.org Git - jquery.git/commitdiff
Only splice from internal arrays when item actually exists.
authorRick Waldron <waldron.rick@gmail.com>
Mon, 31 Dec 2012 23:06:38 +0000 (18:06 -0500)
committerRick Waldron <waldron.rick@gmail.com>
Mon, 31 Dec 2012 23:06:38 +0000 (18:06 -0500)
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
src/data.js

index 6e1465b3b0f9c02f1d8d3e2464c48995a2ab2a56..e6915e9b89bf2cc96a3cc9e864a28e15a4941c03 100644 (file)
@@ -122,8 +122,11 @@ Data.prototype = {
        },
        discard: function( owner ) {
                var index = this.owners.indexOf( owner );
-               this.owners.splice( index, 1 );
-               this.cache.splice( index, 1 );
+
+               if ( index >= 0 ) {
+                       this.owners.splice( index, 1 );
+                       this.cache.splice( index, 1 );
+               }
                return this;
        }
 };