diff options
author | Jacob Wright <jacwright@gmail.com> | 2010-09-07 10:51:57 -0600 |
---|---|---|
committer | jeresig <jeresig@gmail.com> | 2010-09-22 11:38:37 -0400 |
commit | 626624a19a6cbd70b44da08ee2123ba79f8e2bb0 (patch) | |
tree | 77601cde04bd6c6fe6fcc86bb82eaa5d61a1496f /src | |
parent | 1f667aa035b3e4885d6b35fa9aa4990310f131af (diff) | |
download | jquery-626624a19a6cbd70b44da08ee2123ba79f8e2bb0.tar.gz jquery-626624a19a6cbd70b44da08ee2123ba79f8e2bb0.zip |
Fix bug when accessing .data() on an empty set. Return null rather than throwing exception.
Diffstat (limited to 'src')
-rw-r--r-- | src/data.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/data.js b/src/data.js index 562834aa1..b7a6ab972 100644 --- a/src/data.js +++ b/src/data.js @@ -129,8 +129,8 @@ jQuery.extend({ jQuery.fn.extend({ data: function( key, value ) { - if ( typeof key === "undefined" && this.length ) { - return jQuery.data( this[0] ); + if ( typeof key === "undefined" ) { + return this.length ? jQuery.data( this[0] ) : null; } else if ( typeof key === "object" ) { return this.each(function() { |