Depends on jquery/sizzle#177, included with the Sizzle submodule in this commit.
-Subproject commit 8d91687e64f137fac70a8f88d361c5bbb688299f
+Subproject commit 71467207315eaac67dc6ba00992fe0f7998a8cb4
fixture = page.find("[id='qunit-fixture']");
fixtureHTML = fixture.html();
fixture.empty();
- while ( fixture.length && !fixture.prevAll("[id^='qunit-']").length ) {
+ while ( fixture.length && !fixture.prevAll("[id='qunit']").length ) {
fixture = fixture.parent();
}
fixture = fixture.add( fixture.nextAll() );
// Replace the current fixture, including content outside of #qunit-fixture
var oldFixture = originaljQuery("#qunit-fixture");
- while ( oldFixture.length && !oldFixture.prevAll("[id^='qunit-']").length ) {
+ while ( oldFixture.length && !oldFixture.prevAll("[id='qunit']").length ) {
oldFixture = oldFixture.parent();
}
oldFixture.nextAll().remove();
</head>
<body id="body">
- <h1 id="qunit-header"><a href="/jquery/test/index.html">jQuery Test Suite</a></h1>
- <h2 id="qunit-banner"></h2>
- <div id="qunit-testrunner-toolbar"></div>
- <h2 id="qunit-userAgent"></h2>
- <ol id="qunit-tests"></ol>
+ <div id="qunit"></div>
<!-- Test HTML -->
- <div id="nothiddendiv" style="height:1px;background:white;" class="nothiddendiv">
- <div id="nothiddendivchild"></div>
- </div>
<!-- this iframe is outside the #qunit-fixture so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves -->
<iframe id="loadediframe" name="loadediframe" style="display:none;" src="data/iframe.html"></iframe>
<dl id="dl" style="position:absolute;top:-32767px;left:-32767px;width:1px">
<p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p>
</div>
+ <div id="nothiddendiv" style="height:1px;background:white;" class="nothiddendiv">
+ <div id="nothiddendivchild"></div>
+ </div>
<span id="name+value"></span>
<p id="first">Try them out:</p>
<ul id="firstUL"></ul>
var testAddClass = function( valueObj ) {
expect( 9 );
- var div = jQuery("div");
+ var div = jQuery("#qunit-fixture div");
div.addClass( valueObj("test") );
var pass = true;
for ( var i = 0; i < div.size(); i++ ) {
});
test( "addClass(Function) with incoming value", function() {
- expect( 54 );
- var div = jQuery("div"),
+ expect( 52 );
+ var div = jQuery("#qunit-fixture div"),
old = div.map(function() {
return jQuery(this).attr("class") || "";
});
var testRemoveClass = function(valueObj) {
expect( 8 );
- var $set = jQuery("div"),
+ var $set = jQuery("#qunit-fixture div"),
div = document.createElement("div");
$set.addClass("test").removeClass( valueObj("test") );
});
test( "removeClass(Function) with incoming value", function() {
- expect( 54 );
+ expect( 52 );
- var $divs = jQuery("div").addClass("test"), old = $divs.map(function() {
+ var $divs = jQuery("#qunit-fixture div").addClass("test"), old = $divs.map(function() {
return jQuery( this ).attr("class");
});
var submit = 0, div = 0, livea = 0, liveb = 0;
- jQuery("div").live("submit", function(){ submit++; return false; });
- jQuery("div").live("click", function(){ div++; });
+ jQuery("#qunit-fixture div").live("submit", function(){ submit++; return false; });
+ jQuery("#qunit-fixture div").live("click", function(){ div++; });
jQuery("div#nothiddendiv").live("click", function(){ livea++; });
jQuery("div#nothiddendivchild").live("click", function(){ liveb++; });
jQuery("div#nothiddendivchild").die("click");
jQuery("div#nothiddendiv").die("click");
- jQuery("div").die("click");
- jQuery("div").die("submit");
+ jQuery("#qunit-fixture div").die("click");
+ jQuery("#qunit-fixture div").die("submit");
// Test binding with a different context
var clicked = 0, container = jQuery("#qunit-fixture")[0];
jQuery("#foo", container).live("click", function(e){ clicked++; });
- jQuery("div").trigger("click");
+ jQuery("#qunit-fixture div").trigger("click");
jQuery("#foo").trigger("click");
jQuery("#qunit-fixture").trigger("click");
jQuery("body").trigger("click");
var submit = 0, div = 0, livea = 0, liveb = 0;
- jQuery("#body").delegate("div", "submit", function(){ submit++; return false; });
- jQuery("#body").delegate("div", "click", function(){ div++; });
+ jQuery("#body").delegate("#qunit-fixture div", "submit", function(){ submit++; return false; });
+ jQuery("#body").delegate("#qunit-fixture div", "click", function(){ div++; });
jQuery("#body").delegate("div#nothiddendiv", "click", function(){ livea++; });
jQuery("#body").delegate("div#nothiddendivchild", "click", function(){ liveb++; });
jQuery("#body").undelegate("div#nothiddendivchild", "click");
jQuery("#body").undelegate("div#nothiddendiv", "click");
- jQuery("#body").undelegate("div", "click");
- jQuery("#body").undelegate("div", "submit");
+ jQuery("#body").undelegate("#qunit-fixture div", "click");
+ jQuery("#body").undelegate("#qunit-fixture div", "submit");
// Test binding with a different context
var clicked = 0, container = jQuery("#qunit-fixture")[0];
jQuery("#qunit-fixture").delegate("#foo", "click", function(e){ clicked++; });
- jQuery("div").trigger("click");
+ jQuery("#qunit-fixture div").trigger("click");
jQuery("#foo").trigger("click");
jQuery("#qunit-fixture").trigger("click");
jQuery("body").trigger("click");
equal( jQuery(form).clone().children().length, 1, "Make sure we just get the form back." );
body = jQuery("body").clone();
- equal( body.children()[ 0 ].id, "qunit-header", "Make sure cloning body works" );
+ equal( body.children()[ 0 ].id, "qunit", "Make sure cloning body works" );
body.remove();
});
expected.push("B");
actual.push( childNodeNames( this ) );
});
- equal( expected.length, 6, "Expecting many parents" );
+ equal( expected.length, 7, "Expecting many parents" );
deepEqual( actual, expected, "Correct childNodes after setting HTML" );
actual = []; expected = [];
equal( body.length, 1, "Only one offsetParent found." );
equal( body[0], document.documentElement, "The html element is the offsetParent of the body." );
- var header = jQuery("#qunit-header").offsetParent();
+ var header = jQuery("#qunit").offsetParent();
equal( header.length, 1, "Only one offsetParent found." );
- equal( header[0], document.documentElement, "The html element is the offsetParent of the body." );
+ equal( header[0], document.documentElement, "The html element is the offsetParent of #qunit." );
var div = jQuery("#nothiddendivchild").offsetParent();
equal( div.length, 1, "Only one offsetParent found." );
- equal( div[0], document.documentElement, "The html element is the offsetParent of the body." );
+ equal( div[0], document.getElementById("qunit-fixture"), "The #qunit-fixture is the offsetParent of #nothiddendivchild." );
jQuery("#nothiddendiv").css("position", "relative");
test("element - jQuery only", function() {
expect( 7 );
- deepEqual( jQuery("p", document.getElementsByTagName("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
- deepEqual( jQuery("p", "div").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
- deepEqual( jQuery("p", jQuery("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
- deepEqual( jQuery("div").find("p").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
+ var fixture = document.getElementById("qunit-fixture");
+
+ deepEqual( jQuery("p", fixture).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a Node context." );
+ deepEqual( jQuery("p", "#qunit-fixture").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a selector context." );
+ deepEqual( jQuery("p", jQuery("#qunit-fixture")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a jQuery object context." );
+ deepEqual( jQuery("#qunit-fixture").find("p").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context via .find()." );
ok( jQuery("#length").length, "<input name=\"length\"> cannot be found under IE, see #945" );
ok( jQuery("#lengthtest input").length, "<input name=\"length\"> cannot be found under IE, see #945" );
test("pseudo - visibility", function() {
expect( 9 );
- t( "Is Visible", "div:visible:not(#qunit-testrunner-toolbar):lt(2)", ["nothiddendiv", "nothiddendivchild"] );
+ t( "Is Visible", "#qunit-fixture div:visible:lt(2)", ["foo", "nothiddendiv"] );
t( "Is Not Hidden", "#qunit-fixture:hidden", [] );
t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
equal( j.find("div").length, 0, "Check node,textnode,comment to find zero divs" );
equal( j.find("div").andSelf().length, 3, "Check node,textnode,comment to find zero divs, but preserves pushStack" );
- deepEqual( jQuery("#qunit-fixture").find("> div").get(), q( "foo", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest", "fx-test-group" ), "find child elements" );
+ deepEqual( jQuery("#qunit-fixture").find("> div").get(), q( "foo", "nothiddendiv", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest", "fx-test-group" ), "find child elements" );
deepEqual( jQuery("#qunit-fixture").find("> #foo, > #moretests").get(), q( "foo", "moretests" ), "find child elements" );
deepEqual( jQuery("#qunit-fixture").find("> #foo > p").get(), q( "sndp", "en", "sap" ), "find child elements" );
deepEqual( jQuery("body").closest("div").get(), [], "closest(div)" );
deepEqual( jQuery("#qunit-fixture").closest("span,#html").get(), q("html"), "closest(span,#html)" );
- deepEqual( jQuery("div:eq(1)").closest("div:first").get(), [], "closest(div:first)" );
- deepEqual( jQuery("div").closest("body:first div:last").get(), q("fx-tests"), "closest(body:first div:last)" );
+ deepEqual( jQuery("#qunit-fixture").closest("div:first").get(), [], "closest(div:first)" );
+ deepEqual( jQuery("#qunit-fixture div").closest("body:first div:last").get(), q("fx-tests"), "closest(body:first div:last)" );
// Test .closest() limited by the context
var jq = jQuery("#nothiddendivchild");
expect(8);
var $child = jQuery("#nothiddendivchild"),
$parent = jQuery("#nothiddendiv"),
- $main = jQuery("#qunit-fixture"),
+ $sibling = jQuery("#foo"),
$body = jQuery("body");
ok( $child.closest( $parent ).is("#nothiddendiv"), "closest( jQuery('#nothiddendiv') )" );
ok( $child.closest( $parent[0] ).is("#nothiddendiv"), "closest( jQuery('#nothiddendiv') ) :: node" );
ok( $child.closest( $child ).is("#nothiddendivchild"), "child is included" );
ok( $child.closest( $child[0] ).is("#nothiddendivchild"), "child is included :: node" );
equal( $child.closest( document.createElement("div") ).length, 0, "created element is not related" );
- equal( $child.closest( $main ).length, 0, "Main not a parent of child" );
- equal( $child.closest( $main[0] ).length, 0, "Main not a parent of child :: node" );
+ equal( $child.closest( $sibling ).length, 0, "Sibling not a parent of child" );
+ equal( $child.closest( $sibling[0] ).length, 0, "Sibling not a parent of child :: node" );
ok( $child.closest( $body.add($parent) ).is("#nothiddendiv"), "Closest ancestor retrieved." );
});