mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
No ticket. Simplifies data methods and updates comments. Closes gh-1233
This commit is contained in:
parent
ff3f83fdf6
commit
1a3939659b
14
src/data.js
14
src/data.js
@ -92,8 +92,6 @@ Data.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
|
||||||
},
|
},
|
||||||
get: function( owner, key ) {
|
get: function( owner, key ) {
|
||||||
// Either a valid cache is found, or will be created.
|
// Either a valid cache is found, or will be created.
|
||||||
@ -141,6 +139,7 @@ Data.prototype = {
|
|||||||
|
|
||||||
if ( key === undefined ) {
|
if ( key === undefined ) {
|
||||||
this.cache[ unlock ] = {};
|
this.cache[ unlock ] = {};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Support array or space separated string of keys
|
// Support array or space separated string of keys
|
||||||
if ( jQuery.isArray( key ) ) {
|
if ( jQuery.isArray( key ) ) {
|
||||||
@ -210,7 +209,7 @@ jQuery.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
removeData: function( elem, name ) {
|
removeData: function( elem, name ) {
|
||||||
return data_user.remove( elem, name );
|
data_user.remove( elem, name );
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Replace all calls to _data and _removeData with direct
|
// TODO: Replace all calls to _data and _removeData with direct
|
||||||
@ -225,7 +224,7 @@ jQuery.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_removeData: function( elem, name ) {
|
_removeData: function( elem, name ) {
|
||||||
return data_priv.remove( elem, name );
|
data_priv.remove( elem, name );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -297,7 +296,7 @@ jQuery.fn.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We tried really hard, but the data doesn't exist.
|
// We tried really hard, but the data doesn't exist.
|
||||||
return undefined;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the data...
|
// Set the data...
|
||||||
@ -311,10 +310,10 @@ jQuery.fn.extend({
|
|||||||
// This might not apply to all properties...*
|
// This might not apply to all properties...*
|
||||||
data_user.set( this, camelKey, value );
|
data_user.set( this, camelKey, value );
|
||||||
|
|
||||||
// *... In the case of properties that might ACTUALLY
|
// *... In the case of properties that might _actually_
|
||||||
// have dashes, we need to also store a copy of that
|
// have dashes, we need to also store a copy of that
|
||||||
// unchanged property.
|
// unchanged property.
|
||||||
if ( /-/.test( key ) && data !== undefined ) {
|
if ( key.indexOf("-") !== -1 && data !== undefined ) {
|
||||||
data_user.set( this, key, value );
|
data_user.set( this, key, value );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -334,7 +333,6 @@ function dataAttr( elem, key, data ) {
|
|||||||
// If nothing was found internally, try to fetch any
|
// If nothing was found internally, try to fetch any
|
||||||
// data from the HTML5 data-* attribute
|
// data from the HTML5 data-* attribute
|
||||||
if ( data === undefined && elem.nodeType === 1 ) {
|
if ( data === undefined && elem.nodeType === 1 ) {
|
||||||
|
|
||||||
name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
|
name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
|
||||||
data = elem.getAttribute( name );
|
data = elem.getAttribute( name );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user