From 6e3b596514d20124260bc4b3febd8dc105420626 Mon Sep 17 00:00:00 2001 From: John Resig Date: Sat, 16 Apr 2011 17:37:35 -0700 Subject: [PATCH 01/26] Allow function to be passed in as a data object to bind and one. Fixes #6993. --- src/event.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/event.js b/src/event.js index bfd26307..ee3606fe 100644 --- a/src/event.js +++ b/src/event.js @@ -909,7 +909,7 @@ jQuery.each(["bind", "one"], function( i, name ) { return this; } - if ( jQuery.isFunction( data ) || data === false ) { + if ( arguments.length === 2 || data === false ) { fn = data; data = undefined; } From 5d70c6d797af15641a8e562cf5b3d022a1bdda25 Mon Sep 17 00:00:00 2001 From: John Resig Date: Sat, 16 Apr 2011 17:39:30 -0700 Subject: [PATCH 02/26] Add in unit tests for #6993. --- test/unit/event.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/unit/event.js b/test/unit/event.js index 1710f6f9..a1aee191 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -15,7 +15,7 @@ test("null or undefined handler", function() { }); test("bind(), with data", function() { - expect(3); + expect(4); var handler = function(event) { ok( event.data, "bind() with data, check passed data exists" ); equals( event.data.foo, "bar", "bind() with data, Check value of passed data" ); @@ -23,6 +23,12 @@ test("bind(), with data", function() { jQuery("#firstp").bind("click", {foo: "bar"}, handler).click().unbind("click", handler); ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." ); + + var test = function(){}; + var handler2 = function(event) { + equals( event.data, test, "bind() with function data, Check value of passed data" ); + }; + jQuery("#firstp").bind("click", test, handler2).click().unbind("click", handler2); }); test("click(), with data", function() { From ecf6a3c3831ae6afef6273c06e53ee7710877125 Mon Sep 17 00:00:00 2001 From: timmywil Date: Sun, 17 Apr 2011 02:43:57 -0400 Subject: [PATCH 03/26] Switch QUnit div from depreceted #main to #qunit-fixture --- test/index.html | 4 +- test/unit/ajax.js | 4 +- test/unit/attributes.js | 4 +- test/unit/core.js | 78 +++++++++++++++++++-------------------- test/unit/css.js | 2 +- test/unit/data.js | 4 +- test/unit/effects.js | 20 +++++----- test/unit/event.js | 38 +++++++++---------- test/unit/manipulation.js | 70 +++++++++++++++++------------------ test/unit/traversing.js | 68 +++++++++++++++++----------------- 10 files changed, 146 insertions(+), 146 deletions(-) diff --git a/test/index.html b/test/index.html index a1065508..62556272 100644 --- a/test/index.html +++ b/test/index.html @@ -58,10 +58,10 @@
- +
-
+

See this blog entry for more information.

Here are some links in a normal paragraph: Google, diff --git a/test/unit/ajax.js b/test/unit/ajax.js index a8a5fa0d..9f084136 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1782,7 +1782,7 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() { passed++; if ( passed == 2 ) { ok( true, "Check local and global callbacks after timeout" ); - jQuery("#main").unbind("ajaxError"); + jQuery("#qunit-fixture").unbind("ajaxError"); start(); } }; @@ -1792,7 +1792,7 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() { start(); }; - jQuery("#main").ajaxError(pass); + jQuery("#qunit-fixture").ajaxError(pass); jQuery.ajax({ type: "GET", diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 8ea27aa3..a497effa 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -108,7 +108,7 @@ test("attr(String)", function() { equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" ); // using innerHTML in IE causes href attribute to be serialized to the full path - jQuery("").attr({ "id": "tAnchor5", "href": "#5" }).appendTo("#main"); + jQuery("").attr({ "id": "tAnchor5", "href": "#5" }).appendTo("#qunit-fixture"); equals( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" ); // list attribute is readonly by default in browsers that support it @@ -599,7 +599,7 @@ test("val(Function) with incoming value", function() { test("val(select) after form.reset() (Bug #2551)", function() { expect(3); - jQuery("

").appendTo("#main"); + jQuery("
").appendTo("#qunit-fixture"); jQuery("#kkk").val( "gf" ); diff --git a/test/unit/core.js b/test/unit/core.js index 8d29575a..cc744e7b 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -29,7 +29,7 @@ test("jQuery()", function() { equals( jQuery(window).length, 1, "Correct number of elements generated for jQuery(window)" ); - var main = jQuery("#main"); + var main = jQuery("#qunit-fixture"); same( jQuery("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" ); /* @@ -115,54 +115,54 @@ test("selector state", function() { equals( test.selector, "", "Body Selector" ); equals( test.context, document.body, "Body Context" ); - test = jQuery("#main"); - equals( test.selector, "#main", "#main Selector" ); - equals( test.context, document, "#main Context" ); + test = jQuery("#qunit-fixture"); + equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equals( test.context, document, "#qunit-fixture Context" ); test = jQuery("#notfoundnono"); equals( test.selector, "#notfoundnono", "#notfoundnono Selector" ); equals( test.context, document, "#notfoundnono Context" ); - test = jQuery("#main", document); - equals( test.selector, "#main", "#main Selector" ); - equals( test.context, document, "#main Context" ); + test = jQuery("#qunit-fixture", document); + equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equals( test.context, document, "#qunit-fixture Context" ); - test = jQuery("#main", document.body); - equals( test.selector, "#main", "#main Selector" ); - equals( test.context, document.body, "#main Context" ); + test = jQuery("#qunit-fixture", document.body); + equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equals( test.context, document.body, "#qunit-fixture Context" ); // Test cloning test = jQuery(test); - equals( test.selector, "#main", "#main Selector" ); - equals( test.context, document.body, "#main Context" ); + equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equals( test.context, document.body, "#qunit-fixture Context" ); - test = jQuery(document.body).find("#main"); - equals( test.selector, "#main", "#main find Selector" ); - equals( test.context, document.body, "#main find Context" ); + test = jQuery(document.body).find("#qunit-fixture"); + equals( test.selector, "#qunit-fixture", "#qunit-fixture find Selector" ); + equals( test.context, document.body, "#qunit-fixture find Context" ); - test = jQuery("#main").filter("div"); - equals( test.selector, "#main.filter(div)", "#main filter Selector" ); - equals( test.context, document, "#main filter Context" ); + test = jQuery("#qunit-fixture").filter("div"); + equals( test.selector, "#qunit-fixture.filter(div)", "#qunit-fixture filter Selector" ); + equals( test.context, document, "#qunit-fixture filter Context" ); - test = jQuery("#main").not("div"); - equals( test.selector, "#main.not(div)", "#main not Selector" ); - equals( test.context, document, "#main not Context" ); + test = jQuery("#qunit-fixture").not("div"); + equals( test.selector, "#qunit-fixture.not(div)", "#qunit-fixture not Selector" ); + equals( test.context, document, "#qunit-fixture not Context" ); - test = jQuery("#main").filter("div").not("div"); - equals( test.selector, "#main.filter(div).not(div)", "#main filter, not Selector" ); - equals( test.context, document, "#main filter, not Context" ); + test = jQuery("#qunit-fixture").filter("div").not("div"); + equals( test.selector, "#qunit-fixture.filter(div).not(div)", "#qunit-fixture filter, not Selector" ); + equals( test.context, document, "#qunit-fixture filter, not Context" ); - test = jQuery("#main").filter("div").not("div").end(); - equals( test.selector, "#main.filter(div)", "#main filter, not, end Selector" ); - equals( test.context, document, "#main filter, not, end Context" ); + test = jQuery("#qunit-fixture").filter("div").not("div").end(); + equals( test.selector, "#qunit-fixture.filter(div)", "#qunit-fixture filter, not, end Selector" ); + equals( test.context, document, "#qunit-fixture filter, not, end Context" ); - test = jQuery("#main").parent("body"); - equals( test.selector, "#main.parent(body)", "#main parent Selector" ); - equals( test.context, document, "#main parent Context" ); + test = jQuery("#qunit-fixture").parent("body"); + equals( test.selector, "#qunit-fixture.parent(body)", "#qunit-fixture parent Selector" ); + equals( test.context, document, "#qunit-fixture parent Context" ); - test = jQuery("#main").eq(0); - equals( test.selector, "#main.slice(0,1)", "#main eq Selector" ); - equals( test.context, document, "#main eq Context" ); + test = jQuery("#qunit-fixture").eq(0); + equals( test.selector, "#qunit-fixture.slice(0,1)", "#qunit-fixture eq Selector" ); + equals( test.context, document, "#qunit-fixture eq Context" ); var d = "
"; equals( @@ -228,7 +228,7 @@ test("noConflict", function() { equals( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" ); equals( jQuery, originaljQuery, "Make sure jQuery was reverted." ); equals( $, original$, "Make sure $ was reverted." ); - ok( $$("#main").html("test"), "Make sure that jQuery still works." ); + ok( $$("#qunit-fixture").html("test"), "Make sure that jQuery still works." ); jQuery = $$; }); @@ -571,29 +571,29 @@ test("end()", function() { test("length", function() { expect(1); - equals( jQuery("#main p").length, 6, "Get Number of Elements Found" ); + equals( jQuery("#qunit-fixture p").length, 6, "Get Number of Elements Found" ); }); test("size()", function() { expect(1); - equals( jQuery("#main p").size(), 6, "Get Number of Elements Found" ); + equals( jQuery("#qunit-fixture p").size(), 6, "Get Number of Elements Found" ); }); test("get()", function() { expect(1); - same( jQuery("#main p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" ); + same( jQuery("#qunit-fixture p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" ); }); test("toArray()", function() { expect(1); - same( jQuery("#main p").toArray(), + same( jQuery("#qunit-fixture p").toArray(), q("firstp","ap","sndp","en","sap","first"), "Convert jQuery object to an Array" ) }) test("get(Number)", function() { expect(2); - equals( jQuery("#main p").get(0), document.getElementById("firstp"), "Get A Single Element" ); + equals( jQuery("#qunit-fixture p").get(0), document.getElementById("firstp"), "Get A Single Element" ); strictEqual( jQuery("#firstp").get(1), undefined, "Try get with index larger elements count" ); }); diff --git a/test/unit/css.js b/test/unit/css.js index 33bc1548..60e8744c 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -3,7 +3,7 @@ module("css", { teardown: moduleTeardown }); test("css(String|Hash)", function() { expect( 42 ); - equals( jQuery("#main").css("display"), "block", "Check for css property \"display\""); + equals( jQuery("#qunit-fixture").css("display"), "block", "Check for css property \"display\""); ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible"); jQuery("#nothiddendiv").css({display: "none"}); diff --git a/test/unit/data.js b/test/unit/data.js index 888f71cb..8b5ce961 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -316,7 +316,7 @@ test("data-* attributes", function() { div.remove(); - child.appendTo("#main"); + child.appendTo("#qunit-fixture"); equals( child.data("myobj"), "old data", "Value accessed from data-* attribute"); child.data("myobj", "replaced"); @@ -406,7 +406,7 @@ test("data-* attributes", function() { } var metadata = "
  1. Some stuff
  2. Some stuff
  3. Some stuff
  4. Some stuff
", - elem = jQuery(metadata).appendTo("#main"); + elem = jQuery(metadata).appendTo("#qunit-fixture"); elem.find("li").each(testData); elem.remove(); diff --git a/test/unit/effects.js b/test/unit/effects.js index 8b7cf467..5b93b83b 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -2,7 +2,7 @@ module("effects", { teardown: moduleTeardown }); test("sanity check", function() { expect(1); - ok( jQuery("#dl:visible, #main:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects" ); + ok( jQuery("#dl:visible, #qunit-fixture:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects" ); }); test("show()", function() { @@ -14,7 +14,7 @@ test("show()", function() { equals( hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible." ); - var div = jQuery("
").hide().appendTo("#main").show(); + var div = jQuery("
").hide().appendTo("#qunit-fixture").show(); equal( div.css("display"), "block", "Make sure pre-hidden divs show" ); @@ -32,7 +32,7 @@ test("show()", function() { hiddendiv.css("display",""); - var pass = true, div = jQuery("#main div"); + var pass = true, div = jQuery("#qunit-fixture div"); div.show().each(function(){ if ( this.style.display == "none" ) pass = false; }); @@ -62,7 +62,7 @@ test("show()", function() { }); // #show-tests * is set display: none in CSS - jQuery("#main").append("

"); + jQuery("#qunit-fixture").append("

"); var old = jQuery("#test-table").show().css("display") !== "table"; jQuery("#test-table").remove(); @@ -96,7 +96,7 @@ test("show(Number) - other displays", function() { stop(); // #show-tests * is set display: none in CSS - jQuery("#main").append("

"); + jQuery("#qunit-fixture").append("

"); var old = jQuery("#test-table").show().css("display") !== "table", num = 0; @@ -138,7 +138,7 @@ test("Persist correct display value", function() { stop(); // #show-tests * is set display: none in CSS - jQuery("#main").append("
foo
"); + jQuery("#qunit-fixture").append("
foo
"); var $span = jQuery("#show-tests span"), displayNone = $span.css("display"), @@ -581,7 +581,7 @@ jQuery.checkOverflowDisplay = function(){ } test( "jQuery.fx.prototype.cur()", 6, function() { - var div = jQuery( "
" ).appendTo( "#main" ).css({ + var div = jQuery( "
" ).appendTo( "#qunit-fixture" ).css({ color: "#ABC", border: "5px solid black", left: "auto", @@ -954,7 +954,7 @@ test("hide hidden elements (bug #7141)", function() { expect(3); QUnit.reset(); - var div = jQuery("
").appendTo("#main"); + var div = jQuery("
").appendTo("#qunit-fixture"); equals( div.css("display"), "none", "Element is hidden by default" ); div.hide(); ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" ); @@ -969,7 +969,7 @@ test("hide hidden elements, with animation (bug #7141)", function() { QUnit.reset(); stop(); - var div = jQuery("
").appendTo("#main"); + var div = jQuery("
").appendTo("#qunit-fixture"); equals( div.css("display"), "none", "Element is hidden by default" ); div.hide(1, function () { ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" ); @@ -982,7 +982,7 @@ test("hide hidden elements, with animation (bug #7141)", function() { test("animate unit-less properties (#4966)", 2, function() { stop(); - var div = jQuery( "
" ).appendTo( "#main" ); + var div = jQuery( "
" ).appendTo( "#qunit-fixture" ); equal( div.css( "z-index" ), "0", "z-index is 0" ); div.animate({ zIndex: 2 }, function() { equal( div.css( "z-index" ), "2", "z-index is 2" ); diff --git a/test/unit/event.js b/test/unit/event.js index a1aee191..454ada3b 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -169,7 +169,7 @@ test("bind(), namespace with special add", function() { }); // Should trigger 2 - div.appendTo("#main").remove(); + div.appendTo("#qunit-fixture").remove(); delete jQuery.event.special.test; }); @@ -307,7 +307,7 @@ test("live/delegate immediate propagation", function() { test("bind/delegate bubbling, isDefaultPrevented", function() { expect(2); var $anchor2 = jQuery( "#anchor2" ), - $main = jQuery( "#main" ), + $main = jQuery( "#qunit-fixture" ), fakeClick = function($jq) { // Use a native click so we don't get jQuery simulated bubbling if ( document.createEvent ) { @@ -415,7 +415,7 @@ test("bind(), namespaced events, cloned events", 18, function() { }).trigger("tester"); // Make sure events stick with appendTo'd elements (which are cloned) #2027 - jQuery("test").click(function(){ return false; }).appendTo("#main"); + jQuery("test").click(function(){ return false; }).appendTo("#qunit-fixture"); ok( jQuery("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" ); }); @@ -538,7 +538,7 @@ test("bind(name, false), unbind(name, false)", function() { expect(3); var main = 0; - jQuery("#main").bind("click", function(e){ main++; }); + jQuery("#qunit-fixture").bind("click", function(e){ main++; }); jQuery("#ap").trigger("click"); equals( main, 1, "Verify that the trigger happened correctly." ); @@ -553,14 +553,14 @@ test("bind(name, false), unbind(name, false)", function() { equals( main, 1, "Verify that the trigger happened correctly." ); // manually clean up events from elements outside the fixture - jQuery("#main").unbind("click"); + jQuery("#qunit-fixture").unbind("click"); }); test("live(name, false), die(name, false)", function() { expect(3); var main = 0; - jQuery("#main").live("click", function(e){ main++; }); + jQuery("#qunit-fixture").live("click", function(e){ main++; }); jQuery("#ap").trigger("click"); equals( main, 1, "Verify that the trigger happened correctly." ); @@ -573,7 +573,7 @@ test("live(name, false), die(name, false)", function() { jQuery("#ap").die("click", false); jQuery("#ap").trigger("click"); equals( main, 1, "Verify that the trigger happened correctly." ); - jQuery("#main").die("click"); + jQuery("#qunit-fixture").die("click"); }); test("delegate(selector, name, false), undelegate(selector, name, false)", function() { @@ -581,7 +581,7 @@ test("delegate(selector, name, false), undelegate(selector, name, false)", funct var main = 0; - jQuery("#main").delegate("#ap", "click", function(e){ main++; }); + jQuery("#qunit-fixture").delegate("#ap", "click", function(e){ main++; }); jQuery("#ap").trigger("click"); equals( main, 1, "Verify that the trigger happened correctly." ); @@ -594,7 +594,7 @@ test("delegate(selector, name, false), undelegate(selector, name, false)", funct jQuery("#ap").undelegate("#groups", "click", false); jQuery("#groups").trigger("click"); equals( main, 1, "Verify that the trigger happened correctly." ); - jQuery("#main").undelegate("#ap", "click"); + jQuery("#qunit-fixture").undelegate("#ap", "click"); }); test("bind()/trigger()/unbind() on plain object", function() { @@ -798,7 +798,7 @@ test("trigger() bubbling", function() { jQuery(document).bind("click", function(e){ if ( e.target !== document) { doc++; } }); jQuery("html").bind("click", function(e){ html++; }); jQuery("body").bind("click", function(e){ body++; }); - jQuery("#main").bind("click", function(e){ main++; }); + jQuery("#qunit-fixture").bind("click", function(e){ main++; }); jQuery("#ap").bind("click", function(){ ap++; return false; }); jQuery("html").trigger("click"); @@ -812,7 +812,7 @@ test("trigger() bubbling", function() { equals( html, 2, "Body bubble" ); equals( body, 1, "Body bubble" ); - jQuery("#main").trigger("click"); + jQuery("#qunit-fixture").trigger("click"); equals( win, 3, "Main bubble" ); equals( doc, 3, "Main bubble" ); equals( html, 3, "Main bubble" ); @@ -828,7 +828,7 @@ test("trigger() bubbling", function() { // manually clean up events from elements outside the fixture jQuery(document).unbind("click"); - jQuery("html, body, #main").unbind("click"); + jQuery("html, body, #qunit-fixture").unbind("click"); }); test("trigger(type, [data], [fn])", function() { @@ -872,7 +872,7 @@ test("trigger(type, [data], [fn])", function() { pass = true; try { - jQuery("#main table:first").bind("test:test", function(){}).trigger("test:test"); + jQuery("#qunit-fixture table:first").bind("test:test", function(){}).trigger("test:test"); } catch (e) { pass = false; } @@ -1189,11 +1189,11 @@ test(".live()/.die()", function() { jQuery("div").die("submit"); // Test binding with a different context - var clicked = 0, container = jQuery("#main")[0]; + var clicked = 0, container = jQuery("#qunit-fixture")[0]; jQuery("#foo", container).live("click", function(e){ clicked++; }); jQuery("div").trigger("click"); jQuery("#foo").trigger("click"); - jQuery("#main").trigger("click"); + jQuery("#qunit-fixture").trigger("click"); jQuery("body").trigger("click"); equals( clicked, 2, "live with a context" ); @@ -1716,11 +1716,11 @@ test(".delegate()/.undelegate()", function() { jQuery("#body").undelegate("div", "submit"); // Test binding with a different context - var clicked = 0, container = jQuery("#main")[0]; - jQuery("#main").delegate("#foo", "click", function(e){ clicked++; }); + var clicked = 0, container = jQuery("#qunit-fixture")[0]; + jQuery("#qunit-fixture").delegate("#foo", "click", function(e){ clicked++; }); jQuery("div").trigger("click"); jQuery("#foo").trigger("click"); - jQuery("#main").trigger("click"); + jQuery("#qunit-fixture").trigger("click"); jQuery("body").trigger("click"); equals( clicked, 2, "delegate with a context" ); @@ -1728,7 +1728,7 @@ test(".delegate()/.undelegate()", function() { ok( jQuery._data(container, "events").live, "delegate with a context" ); // Test unbinding with a different context - jQuery("#main").undelegate("#foo", "click"); + jQuery("#qunit-fixture").undelegate("#foo", "click"); jQuery("#foo").trigger("click"); equals( clicked, 2, "undelegate with a context"); diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index de65daa1..e0fb369a 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -483,19 +483,19 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() { var div = jQuery("
").click(function(){ ok(true, "Running a cloned click."); }); - div.appendTo("#main, #moretests"); + div.appendTo("#qunit-fixture, #moretests"); - jQuery("#main div:last").click(); + jQuery("#qunit-fixture div:last").click(); jQuery("#moretests div:last").click(); QUnit.reset(); - var div = jQuery("
").appendTo("#main, #moretests"); + var div = jQuery("
").appendTo("#qunit-fixture, #moretests"); equals( div.length, 2, "appendTo returns the inserted elements" ); div.addClass("test"); - ok( jQuery("#main div:last").hasClass("test"), "appendTo element was modified after the insertion" ); + ok( jQuery("#qunit-fixture div:last").hasClass("test"), "appendTo element was modified after the insertion" ); ok( jQuery("#moretests div:last").hasClass("test"), "appendTo element was modified after the insertion" ); QUnit.reset(); @@ -507,10 +507,10 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() { div = jQuery("#moretests div"); - var num = jQuery("#main div").length; - div.remove().appendTo("#main"); + var num = jQuery("#qunit-fixture div").length; + div.remove().appendTo("#qunit-fixture"); - equals( jQuery("#main div").length, num, "Make sure all the removed divs were inserted." ); + equals( jQuery("#qunit-fixture div").length, num, "Make sure all the removed divs were inserted." ); QUnit.reset(); }); @@ -750,7 +750,7 @@ var testReplaceWith = function(val) { ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after element" ); QUnit.reset(); - jQuery("#main").append("
"); + jQuery("#qunit-fixture").append("
"); jQuery("#baz").replaceWith("Baz"); equals( jQuery("#bar").text(),"Baz", "Replace element with text" ); ok( !jQuery("#baz")[0], "Verify that original element is gone, after element" ); @@ -813,14 +813,14 @@ var testReplaceWith = function(val) { QUnit.reset(); - jQuery("#main").append("
"); - equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." ); + jQuery("#qunit-fixture").append("
"); + equals( jQuery("#qunit-fixture").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." ); jQuery("#replaceWith").replaceWith( val("
") ); - equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." ); + equals( jQuery("#qunit-fixture").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." ); jQuery("#replaceWith").replaceWith( val("
") ); - equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." ); + equals( jQuery("#qunit-fixture").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." ); } test("replaceWith(String|Element|Array<Element>|jQuery)", function() { @@ -881,7 +881,7 @@ test("jQuery.clone() (#8017)", function() { ok( jQuery.clone && jQuery.isFunction( jQuery.clone ) , "jQuery.clone() utility exists and is a function."); - var main = jQuery("#main")[0], + var main = jQuery("#qunit-fixture")[0], clone = jQuery.clone( main ); equals( main.childNodes.length, clone.childNodes.length, "Simple child length to ensure a large dom tree copies correctly" ); @@ -890,7 +890,7 @@ test("jQuery.clone() (#8017)", function() { test("clone() (#8070)", function () { expect(2); - jQuery("").appendTo("#main"); + jQuery("").appendTo("#qunit-fixture"); var selects = jQuery(".test8070"); selects.append(""); @@ -1062,7 +1062,7 @@ var testHtml = function(valueObj) { jQuery.scriptorder = 0; - var div = jQuery("#main > div"); + var div = jQuery("#qunit-fixture > div"); div.html(valueObj("test")); var pass = true; for ( var i = 0; i < div.size(); i++ ) { @@ -1079,10 +1079,10 @@ var testHtml = function(valueObj) { ok( /^\xA0$|^ $/.test( space ), "Make sure entities are passed through correctly." ); equals( jQuery("
").html(valueObj("&"))[0].innerHTML, "&", "Make sure entities are passed through correctly." ); - jQuery("#main").html(valueObj("")); + jQuery("#qunit-fixture").html(valueObj("")); - equals( jQuery("#main").children().length, 1, "Make sure there is a child element." ); - equals( jQuery("#main").children()[0].nodeName.toUpperCase(), "STYLE", "And that a style element was inserted." ); + equals( jQuery("#qunit-fixture").children().length, 1, "Make sure there is a child element." ); + equals( jQuery("#qunit-fixture").children()[0].nodeName.toUpperCase(), "STYLE", "And that a style element was inserted." ); QUnit.reset(); // using contents will get comments regular, text, and comment nodes @@ -1093,9 +1093,9 @@ var testHtml = function(valueObj) { j.find("b").removeData(); equals( j.html().replace(/ xmlns="[^"]+"/g, "").toLowerCase(), "bold", "Check node,textnode,comment with html()" ); - jQuery("#main").html(valueObj("")); + jQuery("#qunit-fixture select").html(valueObj("")); + equals( jQuery("#qunit-fixture select").val(), "O2", "Selected option correct" ); var $div = jQuery("
"); equals( $div.html(valueObj( 5 )).html(), "5", "Setting a number as html" ); @@ -1113,23 +1113,23 @@ var testHtml = function(valueObj) { QUnit.reset(); - jQuery("#main").html(valueObj("
")); + jQuery("#qunit-fixture").html(valueObj("
")); - var child = jQuery("#main").find("script"); + var child = jQuery("#qunit-fixture").find("script"); equals( child.length, 2, "Make sure that two non-JavaScript script tags are left." ); equals( child[0].type, "something/else", "Verify type of script tag." ); equals( child[1].type, "something/else", "Verify type of script tag." ); - jQuery("#main").html(valueObj("")); - jQuery("#main").html(valueObj("")); - jQuery("#main").html(valueObj("")); + jQuery("#qunit-fixture").html(valueObj("")); + jQuery("#qunit-fixture").html(valueObj("")); + jQuery("#qunit-fixture").html(valueObj("")); - jQuery("#main").html(valueObj("")); + jQuery("#qunit-fixture").html(valueObj("")); - jQuery("#main").html(valueObj("foo
")); + jQuery("#qunit-fixture").html(valueObj("foo
")); - jQuery("#main").html(valueObj("