Setting the jsonp option to false now inhibits any url manipulation regarding the...
[jquery.git] / src / data.js
index f7f65ef..4d1d1bd 100644 (file)
@@ -9,8 +9,9 @@ jQuery.extend({
        // Please use with caution
        uuid: 0,
 
-       // Unique for each copy of jQuery on the page   
-       expando: "jQuery" + jQuery.now(),
+       // Unique for each copy of jQuery on the page
+       // Non-digits removed to match rinlinejQuery
+       expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
 
        // The following elements throw uncatchable exceptions if you
        // attempt to add expando properties to them.
@@ -21,6 +22,14 @@ jQuery.extend({
                "applet": true
        },
 
+       hasData: function( elem ) {
+               if ( elem.nodeType ) {
+                       elem = jQuery.cache[ elem[jQuery.expando] ];
+               }
+
+               return !!elem && !jQuery.isEmptyObject(elem);
+       },
+
        data: function( elem, name, data ) {
                if ( !jQuery.acceptData( elem ) ) {
                        return;
@@ -138,15 +147,17 @@ jQuery.fn.extend({
 
                if ( typeof key === "undefined" ) {
                        if ( this.length ) {
-                               var attr = this[0].attributes, name;
                                data = jQuery.data( this[0] );
 
-                               for ( var i = 0, l = attr.length; i < l; i++ ) {
-                                       name = attr[i].name;
+                               if ( this[0].nodeType === 1 ) {
+                                       var attr = this[0].attributes, name;
+                                       for ( var i = 0, l = attr.length; i < l; i++ ) {
+                                               name = attr[i].name;
 
-                                       if ( name.indexOf( "data-" ) === 0 ) {
-                                               name = name.substr( 5 );
-                                               dataAttr( this[0], name, data[ name ] );
+                                               if ( name.indexOf( "data-" ) === 0 ) {
+                                                       name = name.substr( 5 );
+                                                       dataAttr( this[0], name, data[ name ] );
+                                               }
                                        }
                                }
                        }