aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/deprecated.js22
-rw-r--r--src/event/alias.js18
-rw-r--r--test/data/testinit.js1
-rw-r--r--test/unit/deprecated.js40
4 files changed, 63 insertions, 18 deletions
diff --git a/src/deprecated.js b/src/deprecated.js
index dfb13e4ae..bc75f098a 100644
--- a/src/deprecated.js
+++ b/src/deprecated.js
@@ -1,2 +1,24 @@
define( function() {
+
+jQuery.fn.extend( {
+
+ bind: function( types, data, fn ) {
+ return this.on( types, null, data, fn );
+ },
+ unbind: function( types, fn ) {
+ return this.off( types, null, fn );
+ },
+
+ delegate: function( selector, types, data, fn ) {
+ return this.on( types, selector, data, fn );
+ },
+ undelegate: function( selector, types, fn ) {
+
+ // ( namespace ) or ( selector, types [, fn] )
+ return arguments.length === 1 ?
+ this.off( selector, "**" ) :
+ this.off( types, selector || "**", fn );
+ }
+} );
+
} );
diff --git a/src/event/alias.js b/src/event/alias.js
index d2bdc5bb8..75467353c 100644
--- a/src/event/alias.js
+++ b/src/event/alias.js
@@ -19,24 +19,6 @@ jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
jQuery.fn.extend( {
hover: function( fnOver, fnOut ) {
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
- },
-
- bind: function( types, data, fn ) {
- return this.on( types, null, data, fn );
- },
- unbind: function( types, fn ) {
- return this.off( types, null, fn );
- },
-
- delegate: function( selector, types, data, fn ) {
- return this.on( types, selector, data, fn );
- },
- undelegate: function( selector, types, fn ) {
-
- // ( namespace ) or ( selector, types [, fn] )
- return arguments.length === 1 ?
- this.off( selector, "**" ) :
- this.off( types, selector || "**", fn );
}
} );
diff --git a/test/data/testinit.js b/test/data/testinit.js
index 903bc9c34..1815d8f7b 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -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",
diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js
index 52c137dc3..797290f3b 100644
--- a/test/unit/deprecated.js
+++ b/test/unit/deprecated.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();
+} ); \ No newline at end of file