Skip to content

Commit 72c4a06

Browse files
victor-homyakovmarkelog
authored andcommitted
Data: speed up $.fn.data() for camel-cased key
Fixes gh-1941 Closes gh-1952
1 parent 1b932bb commit 72c4a06

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/data.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ jQuery.fn.extend({
112112
}
113113

114114
return access( this, function( value ) {
115-
var data,
116-
camelKey = jQuery.camelCase( key );
115+
var data, camelKey;
117116

118117
// The calling jQuery object (element matches) is not empty
119118
// (and therefore has an element appears at this[ 0 ]) and the
@@ -128,6 +127,7 @@ jQuery.fn.extend({
128127
return data;
129128
}
130129

130+
camelKey = jQuery.camelCase( key );
131131
// Attempt to get data from the cache
132132
// with the key camelized
133133
data = dataUser.get( elem, camelKey );
@@ -147,6 +147,7 @@ jQuery.fn.extend({
147147
}
148148

149149
// Set the data...
150+
camelKey = jQuery.camelCase( key );
150151
this.each(function() {
151152
// First, attempt to store a copy or reference of any
152153
// data that might've been store with a camelCased key.

0 commit comments

Comments
 (0)