#7883 .delegate and .live should accept false as the fn arg, like bind
This commit is contained in:
parent
eed3803c98
commit
612a908514
|
@ -1023,10 +1023,15 @@ jQuery.each(["live", "die"], function( i, name ) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( jQuery.isFunction( data ) ) {
|
if ( jQuery.isFunction( data ) || data === false ) {
|
||||||
fn = data;
|
fn = data;
|
||||||
data = undefined;
|
data = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( fn === false ) {
|
||||||
|
fn = returnFalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
types = (types || "").split(" ");
|
types = (types || "").split(" ");
|
||||||
|
|
||||||
|
|
|
@ -527,6 +527,45 @@ test("bind(name, false), unbind(name, false)", function() {
|
||||||
equals( main, 1, "Verify that the trigger happened correctly." );
|
equals( main, 1, "Verify that the trigger happened correctly." );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("live(name, false), die(name, false)", function() {
|
||||||
|
expect(3);
|
||||||
|
|
||||||
|
var main = 0;
|
||||||
|
jQuery("#main").live("click", function(e){ main++; });
|
||||||
|
jQuery("#ap").trigger("click");
|
||||||
|
equals( main, 1, "Verify that the trigger happened correctly." );
|
||||||
|
|
||||||
|
main = 0;
|
||||||
|
jQuery("#ap").live("click", false);
|
||||||
|
jQuery("#ap").trigger("click");
|
||||||
|
equals( main, 0, "Verify that no bubble happened." );
|
||||||
|
|
||||||
|
main = 0;
|
||||||
|
jQuery("#ap").die("click", false);
|
||||||
|
jQuery("#ap").trigger("click");
|
||||||
|
equals( main, 1, "Verify that the trigger happened correctly." );
|
||||||
|
});
|
||||||
|
|
||||||
|
test("delegate(selector, name, false), undelegate(selector, name, false)", function() {
|
||||||
|
expect(3);
|
||||||
|
|
||||||
|
var main = 0;
|
||||||
|
|
||||||
|
jQuery("#main").delegate("#ap", "click", function(e){ main++; });
|
||||||
|
jQuery("#ap").trigger("click");
|
||||||
|
equals( main, 1, "Verify that the trigger happened correctly." );
|
||||||
|
|
||||||
|
main = 0;
|
||||||
|
jQuery("#ap").delegate("#groups", "click", false);
|
||||||
|
jQuery("#groups").trigger("click");
|
||||||
|
equals( main, 0, "Verify that no bubble happened." );
|
||||||
|
|
||||||
|
main = 0;
|
||||||
|
jQuery("#ap").undelegate("#groups", "click", false);
|
||||||
|
jQuery("#groups").trigger("click");
|
||||||
|
equals( main, 1, "Verify that the trigger happened correctly." );
|
||||||
|
});
|
||||||
|
|
||||||
test("bind()/trigger()/unbind() on plain object", function() {
|
test("bind()/trigger()/unbind() on plain object", function() {
|
||||||
expect( 8 );
|
expect( 8 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue