mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Event: Move .bind() and .delegate() to deprecated
Fixes gh-2288 Closes gh-2624
This commit is contained in:
committed by
Oleg Gaidarenko
parent
9748e436ad
commit
ee0854f85b
@@ -286,6 +286,7 @@ this.loadTests = function() {
|
||||
"unit/core.js",
|
||||
"unit/callbacks.js",
|
||||
"unit/deferred.js",
|
||||
"unit/deprecated.js",
|
||||
"unit/support.js",
|
||||
"unit/data.js",
|
||||
"unit/queue.js",
|
||||
|
||||
@@ -1,2 +1,42 @@
|
||||
QUnit.module( "deprecated", { teardown: moduleTeardown } );
|
||||
|
||||
|
||||
QUnit.test( "bind/unbind", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var markup = jQuery(
|
||||
"<div><p><span><b>b</b></span></p></div>"
|
||||
);
|
||||
|
||||
markup
|
||||
.find( "b" )
|
||||
.bind( "click", { bindData: 19 }, function( e, trig ) {
|
||||
assert.equal( e.type, "click", "correct event type" );
|
||||
assert.equal( e.data.bindData, 19, "correct trigger data" );
|
||||
assert.equal( trig, 42, "correct bind data" );
|
||||
assert.equal( e.target.nodeName.toLowerCase(), "b" , "correct element" );
|
||||
} )
|
||||
.trigger( "click", [ 42 ] )
|
||||
.unbind( "click" )
|
||||
.trigger( "click" )
|
||||
.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "delegate/undelegate", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var markup = jQuery(
|
||||
"<div><p><span><b>b</b></span></p></div>"
|
||||
);
|
||||
|
||||
markup
|
||||
.delegate( "b", "click", function( e ) {
|
||||
assert.equal( e.type, "click", "correct event type" );
|
||||
assert.equal( e.target.nodeName.toLowerCase(), "b" , "correct element" );
|
||||
} )
|
||||
.find( "b" )
|
||||
.trigger( "click" )
|
||||
.end()
|
||||
.undelegate( "b", "click" )
|
||||
.remove();
|
||||
} );
|
||||
Reference in New Issue
Block a user