aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/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 /test/unit/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 'test/unit/data.js')
-rw-r--r--test/unit/data.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/unit/data.js b/test/unit/data.js
index ebeb1b4ee..4feba32c0 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -599,3 +599,24 @@ test("Triggering the removeData should not throw exceptions. (#10080)", function
// change the url to trigger unload
frame.attr("src", "data/iframe.html?param=true");
});
+
+test( "Only check element attributes once when calling .data() - #8909", function() {
+ expect( 2 );
+ var testing = {
+ test: "testing",
+ test2: "testing"
+ },
+ element = jQuery( "<div data-test='testing'>" ),
+ node = element[ 0 ];
+
+ // set an attribute using attr to ensure it
+ node.setAttribute( "data-test2", "testing" );
+ deepEqual( element.data(), testing, "Sanity Check" );
+
+ node.setAttribute( "data-test3", "testing" );
+ deepEqual( element.data(), testing, "The data didn't change even though the data-* attrs did" );
+
+ // clean up data cache
+ element.remove();
+
+});