aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.js
diff options
context:
space:
mode:
authorCorey Frang <gnarf@gnarf.net>2011-09-19 16:13:57 -0400
committertimmywil <timmywillisn@gmail.com>2011-09-19 16:13:57 -0400
commit2831cfd072125a51f454346211666c9e11641474 (patch)
treeacc942367a34dda1c9680bc1f81e0461e95884dd /src/data.js
parentd5f144a7bba98212d6fe9e257f722b62baf651f0 (diff)
downloadjquery-2831cfd072125a51f454346211666c9e11641474.tar.gz
jquery-2831cfd072125a51f454346211666c9e11641474.zip
Landing pull request 503. 1.7 data: set a flag in the private data cache to avoid having to scan attributes multiple times - Fixes #8909.
More Details: - https://github.com/jquery/jquery/pull/503 - http://bugs.jquery.com/ticket/8909
Diffstat (limited to 'src/data.js')
-rw-r--r--src/data.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/data.js b/src/data.js
index 9de0da1c5..1c6d1852c 100644
--- a/src/data.js
+++ b/src/data.js
@@ -231,14 +231,15 @@ jQuery.extend({
jQuery.fn.extend({
data: function( key, value ) {
- var data = null;
+ var parts, attr, name,
+ data = null;
if ( typeof key === "undefined" ) {
if ( this.length ) {
data = jQuery.data( this[0] );
- if ( this[0].nodeType === 1 ) {
- var attr = this[0].attributes, name;
+ if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) {
+ attr = this[0].attributes;
for ( var i = 0, l = attr.length; i < l; i++ ) {
name = attr[i].name;
@@ -248,6 +249,7 @@ jQuery.fn.extend({
dataAttr( this[0], name, data[ name ] );
}
}
+ jQuery._data( this[0], "parsedAttrs", true );
}
}
@@ -259,7 +261,7 @@ jQuery.fn.extend({
});
}
- var parts = key.split(".");
+ parts = key.split(".");
parts[1] = parts[1] ? "." + parts[1] : "";
if ( value === undefined ) {