]> source.dussan.org Git - jquery.git/commitdiff
Only need to declare the data once.
authorjeresig <jeresig@gmail.com>
Fri, 22 Oct 2010 03:18:47 +0000 (23:18 -0400)
committerjeresig <jeresig@gmail.com>
Fri, 22 Oct 2010 03:18:47 +0000 (23:18 -0400)
src/data.js

index 31cdc121e9284bd19a89347e0df250634e704711..0407f73ffd299cd1404e84fb96dc59b6c2e0ecae 100644 (file)
@@ -134,9 +134,9 @@ jQuery.extend({
 
 jQuery.fn.extend({
        data: function( key, value ) {
-               if ( typeof key === "undefined" ) {
-                       var data = null;
+               var data = null;
 
+               if ( typeof key === "undefined" ) {
                        if ( this.length ) {
                                var attr = this[0].attributes, name;
                                data = jQuery.data( this[0] );
@@ -163,7 +163,7 @@ jQuery.fn.extend({
                parts[1] = parts[1] ? "." + parts[1] : "";
 
                if ( value === undefined ) {
-                       var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+                       data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
 
                        // Try to fetch any internally stored data first
                        if ( data === undefined && this.length ) {