mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Adds implementation tests for jQuery.event.propHooks #8789
This commit is contained in:
parent
26898f0bc5
commit
92a80cbd05
@ -2460,6 +2460,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();
|
||||
|
Loading…
Reference in New Issue
Block a user