]> source.dussan.org Git - jquery.git/commitdiff
Data: speed up $.fn.data() for camel-cased key
authorVictor Homyakov <vkhomyackov@gmail.com>
Thu, 18 Dec 2014 19:51:44 +0000 (22:51 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Tue, 23 Dec 2014 22:34:40 +0000 (01:34 +0300)
Fixes gh-1941
Closes gh-1952

src/data.js

index 4db2d6c87be87047d69f7b0c17fdfcd1520972d2..21329defae306dc97440c9b5ebabf7fcb2d036f1 100644 (file)
@@ -112,8 +112,7 @@ jQuery.fn.extend({
                }
 
                return access( this, function( value ) {
-                       var data,
-                               camelKey = jQuery.camelCase( key );
+                       var data, camelKey;
 
                        // The calling jQuery object (element matches) is not empty
                        // (and therefore has an element appears at this[ 0 ]) and the
@@ -128,6 +127,7 @@ jQuery.fn.extend({
                                        return data;
                                }
 
+                               camelKey = jQuery.camelCase( key );
                                // Attempt to get data from the cache
                                // with the key camelized
                                data = dataUser.get( elem, camelKey );
@@ -147,6 +147,7 @@ jQuery.fn.extend({
                        }
 
                        // Set the data...
+                       camelKey = jQuery.camelCase( key );
                        this.each(function() {
                                // First, attempt to store a copy or reference of any
                                // data that might've been store with a camelCased key.