aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2007-09-09 23:08:21 +0000
committerJohn Resig <jeresig@gmail.com>2007-09-09 23:08:21 +0000
commitcd6ec6e157f78ab6810ae79c88ebdf6300d5d458 (patch)
tree2f7c56315d1b7db2d54fa66cd75d360fa6f277ab /src
parent139b03af7c2d7e70a26591424f82f09a02132198 (diff)
downloadjquery-cd6ec6e157f78ab6810ae79c88ebdf6300d5d458.tar.gz
jquery-cd6ec6e157f78ab6810ae79c88ebdf6300d5d458.zip
Added an extra check for removing a named cache property - calling it when it didn't exist caused an exception.
Diffstat (limited to 'src')
-rw-r--r--src/core.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/core.js b/src/core.js
index 3fb59f8d5..c1e7d9f1b 100644
--- a/src/core.js
+++ b/src/core.js
@@ -509,14 +509,16 @@ jQuery.extend({
// If we want to remove a specific section of the element's data
if ( name ) {
- // Remove the section of cache data
- delete jQuery.cache[ id ][ name ];
-
- // If we've removed all the data, remove the element's cache
- name = "";
- for ( name in jQuery.cache[ id ] ) break;
- if ( !name )
- jQuery.removeData( elem );
+ if ( jQuery.cache[ id ] ) {
+ // Remove the section of cache data
+ delete jQuery.cache[ id ][ name ];
+
+ // If we've removed all the data, remove the element's cache
+ name = "";
+ for ( name in jQuery.cache[ id ] ) break;
+ if ( !name )
+ jQuery.removeData( elem );
+ }
// Otherwise, we want to remove all of the element's data
} else {