Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libs/bower_components/jquery/src/data.js')
-rw-r--r--libs/bower_components/jquery/src/data.js61
1 files changed, 34 insertions, 27 deletions
diff --git a/libs/bower_components/jquery/src/data.js b/libs/bower_components/jquery/src/data.js
index 612d91ba0e..2c4b95748a 100644
--- a/libs/bower_components/jquery/src/data.js
+++ b/libs/bower_components/jquery/src/data.js
@@ -1,14 +1,15 @@
-define([
+define( [
"./core",
"./var/deletedIds",
"./data/support",
- "./data/accepts"
-], function( jQuery, deletedIds, support ) {
+ "./data/var/acceptData"
+], function( jQuery, deletedIds, support, acceptData ) {
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
rmultiDash = /([A-Z])/g;
function dataAttr( elem, key, data ) {
+
// If nothing was found internally, try to fetch any
// data from the HTML5 data-* attribute
if ( data === undefined && elem.nodeType === 1 ) {
@@ -22,11 +23,12 @@ function dataAttr( elem, key, data ) {
data = data === "true" ? true :
data === "false" ? false :
data === "null" ? null :
+
// Only convert to a number if it doesn't change the string
+data + "" === data ? +data :
rbrace.test( data ) ? jQuery.parseJSON( data ) :
data;
- } catch( e ) {}
+ } catch ( e ) {}
// Make sure we set the data so it isn't changed later
jQuery.data( elem, key, data );
@@ -45,7 +47,7 @@ function isEmptyDataObject( obj ) {
for ( name in obj ) {
// if the public data object is empty, the private is still empty
- if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
+ if ( name === "data" && jQuery.isEmptyObject( obj[ name ] ) ) {
continue;
}
if ( name !== "toJSON" ) {
@@ -57,7 +59,7 @@ function isEmptyDataObject( obj ) {
}
function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
- if ( !jQuery.acceptData( elem ) ) {
+ if ( !acceptData( elem ) ) {
return;
}
@@ -78,11 +80,13 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
// 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)) && data === undefined && typeof name === "string" ) {
+ if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) &&
+ data === undefined && typeof name === "string" ) {
return;
}
if ( !id ) {
+
// Only DOM nodes need a new unique ID for each element since their data
// ends up in the global cache
if ( isNode ) {
@@ -93,6 +97,7 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
}
if ( !cache[ id ] ) {
+
// Avoid exposing jQuery metadata on plain JS objects when the object
// is serialized using JSON.stringify
cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
@@ -146,7 +151,7 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
}
function internalRemoveData( elem, name, pvt ) {
- if ( !jQuery.acceptData( elem ) ) {
+ if ( !acceptData( elem ) ) {
return;
}
@@ -182,10 +187,11 @@ function internalRemoveData( elem, name, pvt ) {
if ( name in thisCache ) {
name = [ name ];
} else {
- name = name.split(" ");
+ name = name.split( " " );
}
}
} else {
+
// If "name" is an array of keys...
// When data is initially created, via ("key", "val") signature,
// keys will be converted to camelCase.
@@ -197,12 +203,12 @@ function internalRemoveData( elem, name, pvt ) {
i = name.length;
while ( i-- ) {
- delete thisCache[ name[i] ];
+ delete thisCache[ name[ i ] ];
}
// If there is no data left in the cache, we want to continue
// and let the cache object itself get destroyed
- if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
+ if ( pvt ? !isEmptyDataObject( thisCache ) : !jQuery.isEmptyObject( thisCache ) ) {
return;
}
}
@@ -229,13 +235,13 @@ function internalRemoveData( elem, name, pvt ) {
/* jshint eqeqeq: true */
delete cache[ id ];
- // When all else fails, null
+ // When all else fails, undefined
} else {
- cache[ id ] = null;
+ cache[ id ] = undefined;
}
}
-jQuery.extend({
+jQuery.extend( {
cache: {},
// The following elements (space-suffixed to avoid Object.prototype collisions)
@@ -243,12 +249,13 @@ jQuery.extend({
noData: {
"applet ": true,
"embed ": true,
+
// ...but Flash objects (which have this classid) *can* handle expandos
"object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
},
hasData: function( elem ) {
- elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
+ elem = elem.nodeType ? jQuery.cache[ elem[ jQuery.expando ] ] : elem[ jQuery.expando ];
return !!elem && !isEmptyDataObject( elem );
},
@@ -268,12 +275,12 @@ jQuery.extend({
_removeData: function( elem, name ) {
return internalRemoveData( elem, name, true );
}
-});
+} );
-jQuery.fn.extend({
+jQuery.fn.extend( {
data: function( key, value ) {
var i, name, data,
- elem = this[0],
+ elem = this[ 0 ],
attrs = elem && elem.attributes;
// Special expections of .data basically thwart jQuery.access,
@@ -293,7 +300,7 @@ jQuery.fn.extend({
if ( attrs[ i ] ) {
name = attrs[ i ].name;
if ( name.indexOf( "data-" ) === 0 ) {
- name = jQuery.camelCase( name.slice(5) );
+ name = jQuery.camelCase( name.slice( 5 ) );
dataAttr( elem, name, data[ name ] );
}
}
@@ -307,17 +314,17 @@ jQuery.fn.extend({
// Sets multiple values
if ( typeof key === "object" ) {
- return this.each(function() {
+ return this.each( function() {
jQuery.data( this, key );
- });
+ } );
}
return arguments.length > 1 ?
// Sets one value
- this.each(function() {
+ this.each( function() {
jQuery.data( this, key, value );
- }) :
+ } ) :
// Gets one value
// Try to fetch any internally stored data first
@@ -325,11 +332,11 @@ jQuery.fn.extend({
},
removeData: function( key ) {
- return this.each(function() {
+ return this.each( function() {
jQuery.removeData( this, key );
- });
+ } );
}
-});
+} );
return jQuery;
-});
+} );