This commit is contained in:
parent
1bd4325cb9
commit
851846aabe
2 changed files with 10 additions and 4 deletions
|
@ -116,7 +116,8 @@ jQuery.event = {
|
|||
// Namespaced event handlers
|
||||
var namespaces = type.split(".");
|
||||
type = namespaces.shift();
|
||||
var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
|
||||
var all = !namespaces.length,
|
||||
namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
|
||||
|
||||
if ( events[type] ) {
|
||||
// remove the given handler for the given type
|
||||
|
@ -127,7 +128,7 @@ jQuery.event = {
|
|||
else
|
||||
for ( var handle in events[type] )
|
||||
// Handle the removal of namespaced events
|
||||
if ( namespace.test(events[type][handle].type) )
|
||||
if ( all || namespace.test(events[type][handle].type) )
|
||||
delete events[type][handle];
|
||||
|
||||
if ( jQuery.event.specialAll[type] )
|
||||
|
|
|
@ -194,6 +194,11 @@ test("unbind(type)", function() {
|
|||
$elem.bind('error error2',error)
|
||||
.unbind('error error2')
|
||||
.trigger('error').triggerHandler('error2');
|
||||
|
||||
message = "unbind without a type or handler";
|
||||
$elem.bind("error error2.test",error)
|
||||
.unbind()
|
||||
.trigger("error").triggerHandler("error2");
|
||||
});
|
||||
|
||||
test("unbind(eventObject)", function() {
|
||||
|
@ -651,14 +656,14 @@ test(".live()/.die()", function() {
|
|||
|
||||
// bind one pair in one order
|
||||
jQuery('span#liveSpan1 a').live('click', function(){ lived++; return false; });
|
||||
jQuery('span#liveSpan1').live('click', function(){ livee++; });
|
||||
jQuery('span#liveSpan1').live('click', function(){ livee++; });
|
||||
|
||||
jQuery('span#liveSpan1 a').click();
|
||||
equals( lived, 1, "Verify that only one first handler occurred." );
|
||||
equals( livee, 0, "Verify that second handler don't." );
|
||||
|
||||
// and one pair in inverse
|
||||
jQuery('#liveHandlerOrder span#liveSpan2').live('click', function(){ livee++; });
|
||||
jQuery('#liveHandlerOrder span#liveSpan2').live('click', function(){ livee++; });
|
||||
jQuery('#liveHandlerOrder span#liveSpan2 a').live('click', function(){ lived++; return false; });
|
||||
|
||||
jQuery('span#liveSpan2 a').click();
|
||||
|
|
Loading…
Reference in a new issue