aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2011-09-24 22:26:41 -0400
committerDave Methvin <dave.methvin@gmail.com>2011-09-24 22:37:16 -0400
commitae27424b30df318a41ea445c296a0d5566a36467 (patch)
treefceeab0515f2f1860329adf7b2a47849c4a9a14d /test
parentd920ac68fdc7c0fc95ec2e9d9c1a4a17d024581b (diff)
parent87e1c62d8e5a916587217196ee7d1755bc9115ca (diff)
downloadjquery-ae27424b30df318a41ea445c296a0d5566a36467.tar.gz
jquery-ae27424b30df318a41ea445c296a0d5566a36467.zip
Merge branch '8789-fun-with-fix' of https://github.com/rwldrn/jquery into fix-8789-rwldrn-fix
Conflicts: src/event.js test/unit/event.js
Diffstat (limited to 'test')
-rw-r--r--test/unit/event.js67
1 files changed, 63 insertions, 4 deletions
diff --git a/test/unit/event.js b/test/unit/event.js
index 9a03bb32c..103b7f00a 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -54,7 +54,7 @@ test("Handler changes and .trigger() order", function() {
markup.find( "b" ).trigger( "click" );
equals( path, "p div body html ", "Delivered all events" )
-
+
markup.remove();
});
*/
@@ -2332,7 +2332,7 @@ test(".on and .off", function() {
// We should have removed all the event handlers ... kinda hacky way to check this
var data = jQuery.data[ jQuery( "#onandoff" )[0].expando ] || {};
equals( data.events, undefined, "no events left" );
-
+
jQuery("#onandoff").remove();
});
@@ -2349,12 +2349,12 @@ test("delegated events quickIs", function() {
'</div>'
),
str,
- check = function(el, expect){
+ check = function(el, expect){
str = "";
markup.find( el ).trigger( "blink" );
equals( str, expect, "On " + el );
},
- func = function(e){
+ func = function(e){
var tag = this.nodeName.toLowerCase();
str += (str && " ") + tag + "|" + e.handleObj.selector;
ok( e.handleObj.quick, "Selector "+ e.handleObj.selector + " on " + tag + " is a quickIs case" );
@@ -2457,6 +2457,65 @@ test("delegated events quickIs", function() {
})();
+test("jQuery.event.propHooks", function() {
+ expect( 1 );
+ ok( jQuery.event.propHooks, "jQuery.event.propHooks exists" );
+});
+
+test("jQuery.event.propHooks as function", function() {
+
+ expect( 2 );
+
+ jQuery( "<div id='hook-fixture'></div>" ).appendTo( "#qunit-fixture" );
+
+ var $fixture = jQuery( "#hook-fixture" );
+
+ // Does not exist
+ $fixture.bind( "click", function( event ) {
+ ok( !("propC" in event), "event.propC Does not exist" );
+ }).trigger( "click" );
+
+ $fixture.unbind( "click" );
+
+ // Store as function
+ jQuery.event.propHooks[ "custom" ] = function( event ) {
+ // receives the event object for processing
+ event.propC = true;
+ return event;
+ };
+
+ $fixture.bind( "custom", function( event ) {
+ ok( event.propC, "event.propC exists" );
+ }).trigger( "custom" );
+});
+
+test("jQuery.event.propHooks usecase", function() {
+
+ expect( 3 );
+
+ jQuery( "<div id='hook-fixture'></div>" ).appendTo( "#qunit-fixture" );
+
+ var $fixture = jQuery( "#hook-fixture" );
+
+ $fixture.bind( "fakedrop", function( event ) {
+ ok( !("dataTransfer" in event), "event.dataTransfer is not available" );
+ }).trigger( "fakedrop" );
+
+ $fixture.unbind( "fakedrop" );
+
+ jQuery.event.propHooks[ "fakedrop" ] = function( event ) {
+ event.dataTransfer = "some val";
+ return event;
+ };
+
+ $fixture.bind( "fakedrop", function( event ) {
+ ok( ("dataTransfer" in event), "event.dataTransfer exists, just copied" );
+ equal( event.dataTransfer, "some val", "event.dataTransfer equal 'some val'" );
+ }).trigger( "fakedrop" );
+
+ $fixture.unbind( "fakedrop" );
+});
+
/*
test("event properties", function() {
stop();