Commit
…to contain the cache ID to avoid it being JSON serialized.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,13 +46,30 @@ jQuery.extend({ | |
// Avoid generating a new cache unless none exists and we | ||
// want to manipulate it. | ||
if ( typeof name === "object" ) { | ||
cache[ id ] = jQuery.extend(true, {}, name); | ||
if ( isNode ) { | ||
cache[ id ] = jQuery.extend(true, {}, name); | ||
} else { | ||
cache[ id ] = function() { | ||
return jQuery.extend(true, {}, name); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nje
Owner
|
||
} | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
|
||
} else if ( !cache[ id ] ) { | ||
cache[ id ] = {}; | ||
if ( isNode ) { | ||
cache[ id ] = {}; | ||
} else { | ||
var store = {}; | ||
cache[ id ] = function() { | ||
return store; | ||
} | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
|
||
} | ||
|
||
thisCache = cache[ id ]; | ||
This comment has been minimized.
Sorry, something went wrong.
jeresig
|
||
if ( !isNode ) { | ||
thisCache = thisCache(); | ||
} | ||
|
||
// Prevent overriding the named cache with undefined values | ||
if ( data !== undefined ) { | ||
|
@@ -71,8 +88,12 @@ jQuery.extend({ | |
windowData : | ||
elem; | ||
|
||
var id = elem[ jQuery.expando ], cache = jQuery.cache, | ||
isNode = elem.nodeType, thisCache = isNode ? cache[ id ] : id; | ||
var isNode = elem.nodeType, | ||
id = elem[ jQuery.expando ], cache = jQuery.cache; | ||
if ( id && !isNode ) { | ||
id = id(); | ||
} | ||
var thisCache = cache[ id ]; | ||
|
||
// If we want to remove a specific section of the element's data | ||
if ( name ) { | ||
|
1 comment
on commit 6be9747
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated per review points:
http://github.com/nje/jquery/commit/2480f851423c21d8d51dffa83313d29ccf85ecf7
It seems like this should only be done on the initial set, not on every call? Perhaps use a similar var store = ...; technique as below?