aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2011-10-26 22:56:26 -0400
committerDave Methvin <dave.methvin@gmail.com>2011-10-26 22:56:26 -0400
commitc82dbf1928f54385e83df9ec6de47616f83fe682 (patch)
tree0dac37ce6bcd6b956034ff5262a7cfa768126f55 /src/data.js
parentc2da514bce84fcd452d5aefa38876a9c8675d8c1 (diff)
downloadjquery-c82dbf1928f54385e83df9ec6de47616f83fe682.tar.gz
jquery-c82dbf1928f54385e83df9ec6de47616f83fe682.zip
Make sure `.data("events")` still works, for now.
Diffstat (limited to 'src/data.js')
-rw-r--r--src/data.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/data.js b/src/data.js
index 24011c6b7..15faa6fdc 100644
--- a/src/data.js
+++ b/src/data.js
@@ -32,7 +32,7 @@ jQuery.extend({
return;
}
- var thisCache, ret,
+ var privateCache, thisCache, ret,
internalKey = jQuery.expando,
getByName = typeof name === "string",
@@ -46,11 +46,12 @@ jQuery.extend({
// Only defining an ID for JS objects if its cache already exists allows
// the code to shortcut on the same path as a DOM node with no cache
- id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
+ id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando,
+ isEvents = name === "events";
// Avoid doing any more work than we need to when trying to get data on an
// object that has no data at all
- if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
+ if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
return;
}
@@ -67,7 +68,7 @@ jQuery.extend({
if ( !cache[ id ] ) {
cache[ id ] = {};
- // Avoids exposing jQuery metadata on plain JS objects when the object
+ // Avoids exposing jQuery metadata on plain JS objects when the object
// is serialized using JSON.stringify
if ( !isNode ) {
cache[ id ].toJSON = jQuery.noop;
@@ -84,7 +85,7 @@ jQuery.extend({
}
}
- thisCache = cache[ id ];
+ privateCache = thisCache = cache[ id ];
// jQuery data() is stored in a separate object inside the object's internal data
// cache in order to avoid key collisions between internal data and user-defined
@@ -103,8 +104,8 @@ jQuery.extend({
// Users should not attempt to inspect the internal events object using jQuery.data,
// it is undocumented and subject to change. But does anyone listen? No.
- if ( name === "events" && !thisCache[name] ) {
- return thisCache[ internalKey ] && thisCache[ internalKey ].events;
+ if ( isEvents && !thisCache[ name ] ) {
+ return privateCache.events;
}
// Check for both converted-to-camel and non-converted data property names