Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit c82dbf1928f54385e83df9ec6de47616f83fe682 1 parent c2da514
Dave Methvin dmethvin authored

Showing 1 changed file with 8 additions and 7 deletions. Show diff stats Hide diff stats

  1. +8 7 src/data.js
15 src/data.js
@@ -32,7 +32,7 @@ jQuery.extend({
32 32 return;
33 33 }
34 34
35   - var thisCache, ret,
  35 + var privateCache, thisCache, ret,
36 36 internalKey = jQuery.expando,
37 37 getByName = typeof name === "string",
38 38
@@ -46,11 +46,12 @@ jQuery.extend({
46 46
47 47 // Only defining an ID for JS objects if its cache already exists allows
48 48 // the code to shortcut on the same path as a DOM node with no cache
49   - id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
  49 + id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando,
  50 + isEvents = name === "events";
50 51
51 52 // Avoid doing any more work than we need to when trying to get data on an
52 53 // object that has no data at all
53   - if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
  54 + if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
54 55 return;
55 56 }
56 57
@@ -67,7 +68,7 @@ jQuery.extend({
67 68 if ( !cache[ id ] ) {
68 69 cache[ id ] = {};
69 70
70   - // Avoids exposing jQuery metadata on plain JS objects when the object
  71 + // Avoids exposing jQuery metadata on plain JS objects when the object
71 72 // is serialized using JSON.stringify
72 73 if ( !isNode ) {
73 74 cache[ id ].toJSON = jQuery.noop;
@@ -84,7 +85,7 @@ jQuery.extend({
84 85 }
85 86 }
86 87
87   - thisCache = cache[ id ];
  88 + privateCache = thisCache = cache[ id ];
88 89
89 90 // jQuery data() is stored in a separate object inside the object's internal data
90 91 // cache in order to avoid key collisions between internal data and user-defined
@@ -103,8 +104,8 @@ jQuery.extend({
103 104
104 105 // Users should not attempt to inspect the internal events object using jQuery.data,
105 106 // it is undocumented and subject to change. But does anyone listen? No.
106   - if ( name === "events" && !thisCache[name] ) {
107   - return thisCache[ internalKey ] && thisCache[ internalKey ].events;
  107 + if ( isEvents && !thisCache[ name ] ) {
  108 + return privateCache.events;
108 109 }
109 110
110 111 // Check for both converted-to-camel and non-converted data property names

0 comments on commit c82dbf1

Please sign in to comment.
Something went wrong with that request. Please try again.