From 4b0c26f0af96da05ab1a0166268c2925a6e6e6ac Mon Sep 17 00:00:00 2001 From: rwldrn Date: Tue, 5 Apr 2011 18:12:50 -0400 Subject: Ticket #8777 undelegate by namespace --- test/unit/event.js | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/unit/event.js b/test/unit/event.js index 2a6d8a669..cc6901ff6 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -685,7 +685,7 @@ test("hover()", function() { test("mouseover triggers mouseenter", function() { expect(1); - + var count = 0, elem = jQuery(""); elem.mouseenter(function () { @@ -693,7 +693,7 @@ test("mouseover triggers mouseenter", function() { }); elem.trigger('mouseover'); equals(count, 1, "make sure mouseover triggers a mouseenter" ); - + elem.remove(); }); @@ -1956,6 +1956,27 @@ test("delegate with submit", function() { 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); @@ -1982,8 +2003,8 @@ test("window resize", function() { test("focusin bubbles", function() { expect(5); - - var input = jQuery( '' ).prependTo( "body" ), + + var input = jQuery( '' ).prependTo( "body" ), order = 0; jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){ @@ -1996,12 +2017,12 @@ test("focusin bubbles", 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" ); @@ -2027,3 +2048,4 @@ test("event properties", function() { }).click(); }); */ + -- cgit v1.2.3 From 6591f6dd9d1c86144903f60e5d19e624c5bf6751 Mon Sep 17 00:00:00 2001 From: jeresig Date: Mon, 11 Apr 2011 11:22:52 -0400 Subject: Fix broken merge. --- test/unit/traversing.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/unit/traversing.js b/test/unit/traversing.js index 6228a0b98..f622082e7 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -223,10 +223,6 @@ test("closest(Array)", function() { same( jQuery("body").closest(["span","html"]), [{selector:"html", elem:document.documentElement, level:2}], "closest([body, html])" ); }); -<<<<<<< HEAD -test("not(Selector|undefined)", function() { - expect(11); -======= test("closest(jQuery)", function() { expect(8); var $child = jQuery("#nothiddendivchild"), @@ -243,9 +239,8 @@ test("closest(jQuery)", function() { ok( $child.closest( $body.add($parent) ).is('#nothiddendiv'), "Closest ancestor retrieved." ); }); -test("not(Selector)", function() { - expect(7); ->>>>>>> 1a167767305202797cf4c839eb64bd7adfb00182 +test("not(Selector|undefined)", function() { + expect(11); equals( jQuery("#main > p#ap > a").not("#google").length, 2, "not('selector')" ); same( jQuery("p").not(".result").get(), q("firstp", "ap", "sndp", "en", "sap", "first"), "not('.class')" ); same( jQuery("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" ); -- cgit v1.2.3 From a564a0b1ec167b2f0fdd2d017a986b226a9850f6 Mon Sep 17 00:00:00 2001 From: timmywil Date: Mon, 11 Apr 2011 12:24:31 -0400 Subject: Run order problem when running full test suite in Opera 11, removed failing test as it passed by itself and there are others just like it --- src/traversing.js | 4 ++-- test/unit/traversing.js | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/src/traversing.js b/src/traversing.js index 485de56d4..e0f40151d 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -73,9 +73,9 @@ jQuery.fn.extend({ }, is: function( selector ) { - return !!selector && (typeof selector === "string" ? + return !!selector && ( typeof selector === "string" ? jQuery.filter( selector, this ).length > 0 : - this.filter( selector ).length > 0); + this.filter( selector ).length > 0 ); }, closest: function( selectors, context ) { diff --git a/test/unit/traversing.js b/test/unit/traversing.js index f622082e7..140b337aa 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -72,7 +72,7 @@ test("is(String|undefined)", function() { }); test("is(jQuery)", function() { - expect(24); + expect(23); ok( jQuery('#form').is( jQuery('form') ), 'Check for element: A form is a form' ); ok( !jQuery('#form').is( jQuery('div') ), 'Check for element: A form is not a div' ); ok( jQuery('#mark').is( jQuery('.blog') ), 'Check for class: Expected class "blog"' ); @@ -83,7 +83,6 @@ test("is(jQuery)", function() { ok( !jQuery('#en').is( jQuery('[lang="de"]') ), 'Check for attribute: Expected attribute lang to be "en", not "de"' ); ok( jQuery('#text1').is( jQuery('[type="text"]') ), 'Check for attribute: Expected attribute type to be "text"' ); ok( !jQuery('#text1').is( jQuery('[type="radio"]') ), 'Check for attribute: Expected attribute type to be "text", not "radio"' ); - ok( jQuery('#text2').is( jQuery(':disabled') ), 'Check for pseudoclass: Expected to be disabled' ); ok( !jQuery('#text1').is( jQuery(':disabled') ), 'Check for pseudoclass: Expected not disabled' ); ok( jQuery('#radio2').is( jQuery(':checked') ), 'Check for pseudoclass: Expected to be checked' ); ok( !jQuery('#radio1').is( jQuery(':checked') ), 'Check for pseudoclass: Expected not checked' ); -- cgit v1.2.3