// Create "bubbling" focus and blur events
if ( document.addEventListener ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
-
+
// Attach a single capturing handler while someone wants focusin/focusout
var attaches = 0;
-
+
jQuery.event.special[ fix ] = {
setup: function() {
if ( attaches++ === 0 ) {
return this;
}
+ if ( name === "die" && !types &&
+ origSelector && origSelector[0] === "." ) {
+
+ context.unbind( origSelector );
+
+ return this;
+ }
+
if ( jQuery.isFunction( data ) ) {
fn = data;
data = undefined;
});
})( jQuery );
+
test("mouseover triggers mouseenter", function() {
expect(1);
-
+
var count = 0,
elem = jQuery("<a />");
elem.mouseenter(function () {
});
elem.trigger('mouseover');
equals(count, 1, "make sure mouseover triggers a mouseenter" );
-
+
elem.remove();
});
jQuery(document).undelegate();
});
+test("undelegate() with only namespaces", function(){
+ expect(2);
+
+ var $delegate = jQuery("#liveHandlerOrder"),
+ count = 0;
+
+ $delegate.delegate("a", "click.ns", function(e) {
+ count++;
+ });
+
+ jQuery("a", $delegate).eq(0).trigger("click.ns");
+
+ equals( count, 1, "delegated click.ns");
+
+ $delegate.undelegate(".ns");
+
+ jQuery("a", $delegate).eq(1).trigger("click.ns");
+
+ equals( count, 1, "no more .ns after undelegate");
+});
+
test("Non DOM element events", function() {
expect(1);
test("focusin bubbles", function() {
expect(5);
-
- var input = jQuery( '<input type="text" />' ).prependTo( "body" ),
+
+ var input = jQuery( '<input type="text" />' ).prependTo( "body" ),
order = 0;
jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){
// DOM focus method
input[0].focus();
-
+
// To make the next focus test work, we need to take focus off the input.
// This will fire another focusin event, so set order to reflect that.
order = 1;
jQuery("#text1")[0].focus();
-
+
// jQuery trigger, which calls DOM focus
order = 0;
input.trigger( "focus" );
}).click();
});
*/
+