File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ jQuery.extend({
2323 if ( data !== undefined )
2424 jQuery . cache [ id ] [ name ] = data ;
2525
26+ if ( name === true ) return jQuery . cache [ id ]
27+
2628 // Return the named cache data, or the ID for the element
2729 return name ?
2830 jQuery . cache [ id ] [ name ] :
@@ -98,6 +100,8 @@ jQuery.extend({
98100
99101jQuery . fn . extend ( {
100102 data : function ( key , value ) {
103+ if ( typeof key === "undefined" && this . length ) return jQuery . data ( this [ 0 ] , true ) ;
104+
101105 var parts = key . split ( "." ) ;
102106 parts [ 1 ] = parts [ 1 ] ? "." + parts [ 1 ] : "" ;
103107
Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ test("jQuery.data", function() {
1515} ) ;
1616
1717test ( ".data()" , function ( ) {
18+ expect ( 1 ) ;
19+
20+ var div = jQuery ( "#foo" ) ;
21+ div . data ( "test" , "success" ) ;
22+ isObj ( div . data ( ) , { test : "success" } , "data() get the entire data object" )
23+ } )
24+
25+ test ( ".data(String) and .data(String, Object)" , function ( ) {
1826 expect ( 22 ) ;
1927 var div = jQuery ( "#foo" ) ;
2028 equals ( div . data ( "test" ) , undefined , "Check for no data exists" ) ;
You can’t perform that action at this time.
0 commit comments