aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/data.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2012-10-31 13:55:51 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-10-31 21:27:42 -0400
commite8cf41a051a62bf1f19beab1a5c1d643f121e28e (patch)
treed7b837d94652883ee04254387e61f9b3cf5ebe22 /test/unit/data.js
parent6e75fe5f1945893cce3ced481e586d8ad6cbfa1d (diff)
downloadjquery-e8cf41a051a62bf1f19beab1a5c1d643f121e28e.tar.gz
jquery-e8cf41a051a62bf1f19beab1a5c1d643f121e28e.zip
Fix #10544. Remove deprecated .data() event namespaced triggering.
Data events were horribly slow, never documented, and caused strange interpretation of data items with dots in them.
Diffstat (limited to 'test/unit/data.js')
-rw-r--r--test/unit/data.js59
1 files changed, 1 insertions, 58 deletions
diff --git a/test/unit/data.js b/test/unit/data.js
index 378750108..f861ee4a2 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -175,15 +175,10 @@ test(".data()", function() {
});
test(".data(String) and .data(String, Object)", function() {
- expect(29);
+ expect( 12 );
var parent = jQuery("<div><div></div></div>"),
div = parent.children();
- parent
- .bind("getData", function(){ ok( false, "getData bubbled." ); })
- .bind("setData", function(){ ok( false, "setData bubbled." ); })
- .bind("changeData", function(){ ok( false, "changeData bubbled." ); });
-
ok( div.data("test") === undefined, "Check for no data exists" );
div.data("test", "success");
@@ -199,58 +194,6 @@ test(".data(String) and .data(String, Object)", function() {
ok( div.data("notexist") === undefined, "Check for no data exists" );
- div.data("test", "overwritten");
- var hits = {test:0}, gets = {test:0}, changes = {test:0, value:null};
-
-
- function logChangeData(e,key,value) {
- var dataKey = key;
- if ( e.namespace ) {
- dataKey = dataKey + "." + e.namespace;
- }
- changes[key] += value;
- changes.value = jQuery.data(e.target, dataKey);
- }
-
- div
- .bind("setData",function(e,key,value){ hits[key] += value; })
- .bind("setData.foo",function(e,key,value){ hits[key] += value; })
- .bind("changeData",logChangeData)
- .bind("changeData.foo",logChangeData)
- .bind("getData",function(e,key){ gets[key] += 1; })
- .bind("getData.foo",function(e,key){ gets[key] += 3; });
-
- div.data("test.foo", 2);
- equal( div.data("test"), "overwritten", "Check for original data" );
- equal( div.data("test.foo"), 2, "Check for namespaced data" );
- equal( div.data("test.bar"), "overwritten", "Check for unmatched namespace" );
- equal( hits.test, 2, "Check triggered setter functions" );
- equal( gets.test, 5, "Check triggered getter functions" );
- equal( changes.test, 2, "Check sets raise changeData");
- equal( changes.value, 2, "Check changeData after data has been set" );
-
- hits.test = 0;
- gets.test = 0;
- changes.test = 0;
- changes.value = null;
-
- div.data("test", 1);
- equal( div.data("test"), 1, "Check for original data" );
- equal( div.data("test.foo"), 2, "Check for namespaced data" );
- equal( div.data("test.bar"), 1, "Check for unmatched namespace" );
- equal( hits.test, 1, "Check triggered setter functions" );
- equal( gets.test, 5, "Check triggered getter functions" );
- equal( changes.test, 1, "Check sets raise changeData" );
- equal( changes.value, 1, "Check changeData after data has been set" );
-
- div
- .bind("getData",function(e,key){ return key + "root"; })
- .bind("getData.foo",function(e,key){ return key + "foo"; });
-
- equal( div.data("test"), "testroot", "Check for original data" );
- equal( div.data("test.foo"), "testfoo", "Check for namespaced data" );
- equal( div.data("test.bar"), "testroot", "Check for unmatched namespace" );
-
// #3748
var $elem = jQuery({exists:true});
equal( $elem.data("nothing"), undefined, "Non-existent data returns undefined");