Commit c82dbf19 authored by Dave Methvin's avatar Dave Methvin

Make sure `.data("events")` still works, for now.

parent c2da514b
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment