Commit 73b31553 authored by Rick Waldron's avatar Rick Waldron

Better approach the hasData side effects fix. Thanks gibson042

Signed-off-by: 's avatarRick Waldron <waldron.rick@gmail.com>
parent 5b59a63b
...@@ -21,17 +21,11 @@ function Data() { ...@@ -21,17 +21,11 @@ function Data() {
Data.uid = 1; Data.uid = 1;
Data.prototype = { Data.prototype = {
key: function( owner, options ) { key: function( owner ) {
var descriptor = {}, var descriptor = {},
// Check if the owner object already has a cache key // Check if the owner object already has a cache key
unlock = owner[ this.expando ]; unlock = owner[ this.expando ];
// `readonly` calls from hasData, on owners with no key
// should not create new/empty cache records
if ( !unlock && (options && options.readonly) ) {
return null;
}
// If not, create one // If not, create one
if ( !unlock ) { if ( !unlock ) {
unlock = Data.uid++; unlock = Data.uid++;
...@@ -164,7 +158,7 @@ Data.prototype = { ...@@ -164,7 +158,7 @@ Data.prototype = {
}, },
hasData: function( owner ) { hasData: function( owner ) {
return !jQuery.isEmptyObject( return !jQuery.isEmptyObject(
this.cache[ this.key( owner, { readonly: true }) ] || {} this.cache[ owner[ this.expando ] ] || {}
); );
}, },
discard: function( owner ) { discard: function( owner ) {
......
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