@@ -168,7 +168,7 @@ test("XML Document Selectors", function() {
});

test("broken", function() {
expect( 22 );
expect( 26 );

function broken( name, selector ) {
raises(function() {
@@ -206,6 +206,10 @@ test("broken", function() {
broken( "First-child", ":first-child(n)" );
broken( "Last-child", ":last-child(n)" );
broken( "Only-child", ":only-child(n)" );
broken( "Nth-last-last-child", ":nth-last-last-child(1)" );
broken( "First-last-child", ":first-last-child" );
broken( "Last-last-child", ":last-last-child" );
broken( "Only-last-child", ":only-last-child" );

// Make sure attribute value quoting works correctly. See: #6093
var attrbad = jQuery('<input type="hidden" value="2" name="foo.baz" id="attrbad1"/><input type="hidden" value="2" name="foo[baz]" id="attrbad2"/>').appendTo("body");
@@ -531,63 +535,137 @@ test("attributes", function() {
div = null;
});

test("pseudo - child", function() {
expect( 43 );
t( "First Child", "#qunit-fixture p:first-child", ["firstp","sndp"] );
t( "First Child (case-insensitive)", "#qunit-fixture p:FIRST-CHILD", ["firstp","sndp"] );
t( "Last Child", "p:last-child", ["sap"] );
t( "Only Child", "#qunit-fixture a:only-child", ["simon1","anchor1","yahoo","anchor2","liveLink1","liveLink2"] );
test("pseudo - (parent|empty)", function() {
expect( 3 );
t( "Empty", "ul:empty", ["firstUL"] );
t( "Empty with comment node", "ol:empty", ["empty"] );
t( "Is A Parent", "#qunit-fixture p:parent", ["firstp","ap","sndp","en","sap","first"] );
});

test("pseudo - (first|last|only)-(child|of-type)", function() {
expect( 12 );

t( "First Child", "p:first-child", ["firstp","sndp"] );
t( "First Child", ".nothiddendiv div:first-child", ["nothiddendivchild"] );
t( "Nth Child", "p:nth-child(1)", ["firstp","sndp"] );
t( "Nth Child With Whitespace", "p:nth-child( 1 )", ["firstp","sndp"] );
t( "Not Nth Child", "#qunit-fixture p:not(:nth-child(1))", ["ap","en","sap","first"] );
t( "First Child (leading id)", "#qunit-fixture p:first-child", ["firstp","sndp"] );
t( "First Child (leading class)", ".nothiddendiv div:first-child", ["nothiddendivchild"] );
t( "First Child (case-insensitive)", "#qunit-fixture p:FIRST-CHILD", ["firstp","sndp"] );

t( "Last Child", "p:last-child", ["sap"] );
t( "Last Child (leading id)", "#qunit-fixture a:last-child", ["simon1","anchor1","mark","yahoo","anchor2","simon","liveLink1","liveLink2"] );

t( "Only Child", "#qunit-fixture a:only-child", ["simon1","anchor1","yahoo","anchor2","liveLink1","liveLink2"] );

t( "First-of-type", "#qunit-fixture > p:first-of-type", ["firstp"] );
t( "Last-of-type", "#qunit-fixture > p:last-of-type", ["first"] );
t( "Only-of-type", "#qunit-fixture > :only-of-type", ["name+value", "firstUL", "empty", "floatTest", "iframe", "table"] );

// Verify that the child position isn't being cached improperly
var firstChildren = jQuery("p:first-child").before("<div></div>");
var secondChildren = jQuery("p:nth-child(2)").before("<div></div>");

t( "No longer First Child", "p:nth-child(1)", [] );
firstChildren.prev().remove();
t( "Restored First Child", "p:nth-child(1)", ["firstp","sndp"] );
t( "No longer second child", "p:nth-child(2)", [] );
secondChildren.prev().remove();
t( "Restored second child", "p:nth-child(2)", ["ap","en"] );
});

QUnit.reset();
test("pseudo - nth-child", function() {
expect( 30 );

t( "Nth-child", "p:nth-child(1)", ["firstp","sndp"] );
t( "Nth-child (with whitespace)", "p:nth-child( 1 )", ["firstp","sndp"] );
t( "Nth-child (case-insensitive)", "#form select:first option:NTH-child(3)", ["option1c"] );
t( "Not nth-child", "#qunit-fixture p:not(:nth-child(1))", ["ap","en","sap","first"] );

t( "Nth-child(2)", "#qunit-fixture form#form > *:nth-child(2)", ["text1"] );
t( "Nth-child(2)", "#qunit-fixture form#form > :nth-child(2)", ["text1"] );

t( "Nth-child(-1)", "#form select:first option:nth-child(-1)", [] );
t( "Nth-child(3)", "#form select:first option:nth-child(3)", ["option1c"] );
t( "Nth-child(0n+3)", "#form select:first option:nth-child(0n+3)", ["option1c"] );
t( "Nth-child(1n+0)", "#form select:first option:nth-child(1n+0)", ["option1a", "option1b", "option1c", "option1d"] );
t( "Nth-child(1n)", "#form select:first option:nth-child(1n)", ["option1a", "option1b", "option1c", "option1d"] );
t( "Nth-child(n)", "#form select:first option:nth-child(n)", ["option1a", "option1b", "option1c", "option1d"] );
t( "Nth-child(even)", "#form select:first option:nth-child(even)", ["option1b", "option1d"] );
t( "Nth-child(odd)", "#form select:first option:nth-child(odd)", ["option1a", "option1c"] );
t( "Nth-child(2n)", "#form select:first option:nth-child(2n)", ["option1b", "option1d"] );
t( "Nth-child(2n+1)", "#form select:first option:nth-child(2n+1)", ["option1a", "option1c"] );
t( "Nth-child(2n + 1)", "#form select:first option:nth-child(2n + 1)", ["option1a", "option1c"] );
t( "Nth-child(+2n + 1)", "#form select:first option:nth-child(+2n + 1)", ["option1a", "option1c"] );
t( "Nth-child(3n)", "#form select:first option:nth-child(3n)", ["option1c"] );
t( "Nth-child(3n+1)", "#form select:first option:nth-child(3n+1)", ["option1a", "option1d"] );
t( "Nth-child(3n+2)", "#form select:first option:nth-child(3n+2)", ["option1b"] );
t( "Nth-child(3n+3)", "#form select:first option:nth-child(3n+3)", ["option1c"] );
t( "Nth-child(3n-1)", "#form select:first option:nth-child(3n-1)", ["option1b"] );
t( "Nth-child(3n-2)", "#form select:first option:nth-child(3n-2)", ["option1a", "option1d"] );
t( "Nth-child(3n-3)", "#form select:first option:nth-child(3n-3)", ["option1c"] );
t( "Nth-child(3n+0)", "#form select:first option:nth-child(3n+0)", ["option1c"] );
t( "Nth-child(-1n+3)", "#form select:first option:nth-child(-1n+3)", ["option1a", "option1b", "option1c"] );
t( "Nth-child(-n+3)", "#form select:first option:nth-child(-n+3)", ["option1a", "option1b", "option1c"] );
t( "Nth-child(-1n + 3)", "#form select:first option:nth-child(-1n + 3)", ["option1a", "option1b", "option1c"] );

deepEqual( Sizzle( ":nth-child(n)", null, null, [ document.createElement("a") ].concat( q("ap") ) ), q("ap"), "Seeded nth-child" );
});

t( "Last Child", "p:last-child", ["sap"] );
t( "Last Child", "#qunit-fixture a:last-child", ["simon1","anchor1","mark","yahoo","anchor2","simon","liveLink1","liveLink2"] );

t( "Nth-child", "#qunit-fixture form#form > *:nth-child(2)", ["text1"] );
t( "Nth-child", "#qunit-fixture form#form > :nth-child(2)", ["text1"] );

t( "Nth-child", "#form select:first option:nth-child(-1)", [] );
t( "Nth-child", "#form select:first option:nth-child(3)", ["option1c"] );
t( "Nth-child(case-insensitive)", "#form select:first option:NTH-child(3)", ["option1c"] );
t( "Nth-child", "#form select:first option:nth-child(0n+3)", ["option1c"] );
t( "Nth-child", "#form select:first option:nth-child(1n+0)", ["option1a", "option1b", "option1c", "option1d"] );
t( "Nth-child", "#form select:first option:nth-child(1n)", ["option1a", "option1b", "option1c", "option1d"] );
t( "Nth-child", "#form select:first option:nth-child(n)", ["option1a", "option1b", "option1c", "option1d"] );
t( "Nth-child", "#form select:first option:nth-child(even)", ["option1b", "option1d"] );
t( "Nth-child", "#form select:first option:nth-child(odd)", ["option1a", "option1c"] );
t( "Nth-child", "#form select:first option:nth-child(2n)", ["option1b", "option1d"] );
t( "Nth-child", "#form select:first option:nth-child(2n+1)", ["option1a", "option1c"] );
t( "Nth-child", "#form select:first option:nth-child(2n + 1)", ["option1a", "option1c"] );
t( "Nth-child", "#form select:first option:nth-child(+2n + 1)", ["option1a", "option1c"] );
t( "Nth-child", "#form select:first option:nth-child(3n)", ["option1c"] );
t( "Nth-child", "#form select:first option:nth-child(3n+1)", ["option1a", "option1d"] );
t( "Nth-child", "#form select:first option:nth-child(3n+2)", ["option1b"] );
t( "Nth-child", "#form select:first option:nth-child(3n+3)", ["option1c"] );
t( "Nth-child", "#form select:first option:nth-child(3n-1)", ["option1b"] );
t( "Nth-child", "#form select:first option:nth-child(3n-2)", ["option1a", "option1d"] );
t( "Nth-child", "#form select:first option:nth-child(3n-3)", ["option1c"] );
t( "Nth-child", "#form select:first option:nth-child(3n+0)", ["option1c"] );
t( "Nth-child", "#form select:first option:nth-child(-1n+3)", ["option1a", "option1b", "option1c"] );
t( "Nth-child", "#form select:first option:nth-child(-n+3)", ["option1a", "option1b", "option1c"] );
t( "Nth-child", "#form select:first option:nth-child(-1n + 3)", ["option1a", "option1b", "option1c"] );

deepEqual( Sizzle( ":nth-child(n)", null, null, jQuery("<a></a>").add("#ap") ), q("ap"), "Seeded nth-child" );
test("pseudo - nth-last-child", function() {
expect( 30 );

t( "Nth-last-child", "form:nth-last-child(5)", ["testForm"] );
t( "Nth-last-child (with whitespace)", "form:nth-last-child( 5 )", ["testForm"] );
t( "Nth-last-child (case-insensitive)", "#form select:first option:NTH-last-child(3)", ["option1b"] );
t( "Not nth-last-child", "#qunit-fixture p:not(:nth-last-child(1))", ["firstp", "ap", "sndp", "en", "first"] );

t( "Nth-last-child(-1)", "#form select:first option:nth-last-child(-1)", [] );
t( "Nth-last-child(3)", "#form select:first :nth-last-child(3)", ["option1b"] );
t( "Nth-last-child(3)", "#form select:first *:nth-last-child(3)", ["option1b"] );
t( "Nth-last-child(3)", "#form select:first option:nth-last-child(3)", ["option1b"] );
t( "Nth-last-child(0n+3)", "#form select:first option:nth-last-child(0n+3)", ["option1b"] );
t( "Nth-last-child(1n+0)", "#form select:first option:nth-last-child(1n+0)", ["option1a", "option1b", "option1c", "option1d"] );
t( "Nth-last-child(1n)", "#form select:first option:nth-last-child(1n)", ["option1a", "option1b", "option1c", "option1d"] );
t( "Nth-last-child(n)", "#form select:first option:nth-last-child(n)", ["option1a", "option1b", "option1c", "option1d"] );
t( "Nth-last-child(even)", "#form select:first option:nth-last-child(even)", ["option1a", "option1c"] );
t( "Nth-last-child(odd)", "#form select:first option:nth-last-child(odd)", ["option1b", "option1d"] );
t( "Nth-last-child(2n)", "#form select:first option:nth-last-child(2n)", ["option1a", "option1c"] );
t( "Nth-last-child(2n+1)", "#form select:first option:nth-last-child(2n+1)", ["option1b", "option1d"] );
t( "Nth-last-child(2n + 1)", "#form select:first option:nth-last-child(2n + 1)", ["option1b", "option1d"] );
t( "Nth-last-child(+2n + 1)", "#form select:first option:nth-last-child(+2n + 1)", ["option1b", "option1d"] );
t( "Nth-last-child(3n)", "#form select:first option:nth-last-child(3n)", ["option1b"] );
t( "Nth-last-child(3n+1)", "#form select:first option:nth-last-child(3n+1)", ["option1a", "option1d"] );
t( "Nth-last-child(3n+2)", "#form select:first option:nth-last-child(3n+2)", ["option1c"] );
t( "Nth-last-child(3n+3)", "#form select:first option:nth-last-child(3n+3)", ["option1b"] );
t( "Nth-last-child(3n-1)", "#form select:first option:nth-last-child(3n-1)", ["option1c"] );
t( "Nth-last-child(3n-2)", "#form select:first option:nth-last-child(3n-2)", ["option1a", "option1d"] );
t( "Nth-last-child(3n-3)", "#form select:first option:nth-last-child(3n-3)", ["option1b"] );
t( "Nth-last-child(3n+0)", "#form select:first option:nth-last-child(3n+0)", ["option1b"] );
t( "Nth-last-child(-1n+3)", "#form select:first option:nth-last-child(-1n+3)", ["option1b", "option1c", "option1d"] );
t( "Nth-last-child(-n+3)", "#form select:first option:nth-last-child(-n+3)", ["option1b", "option1c", "option1d"] );
t( "Nth-last-child(-1n + 3)", "#form select:first option:nth-last-child(-1n + 3)", ["option1b", "option1c", "option1d"] );

deepEqual( Sizzle( ":nth-last-child(n)", null, null, [ document.createElement("a") ].concat( q("ap") ) ), q("ap"), "Seeded nth-last-child" );
});

test("pseudo - nth-of-type", function() {
expect( 9 );
t( "Nth-of-type(-1)", ":nth-of-type(-1)", [] );
t( "Nth-of-type(3)", "#ap :nth-of-type(3)", ["mark"] );
t( "Nth-of-type(n)", "#ap :nth-of-type(n)", ["google", "groups", "code1", "anchor1", "mark"] );
t( "Nth-of-type(0n+3)", "#ap :nth-of-type(0n+3)", ["mark"] );
t( "Nth-of-type(2n)", "#ap :nth-of-type(2n)", ["groups"] );
t( "Nth-of-type(even)", "#ap :nth-of-type(even)", ["groups"] );
t( "Nth-of-type(2n+1)", "#ap :nth-of-type(2n+1)", ["google", "code1", "anchor1", "mark"] );
t( "Nth-of-type(odd)", "#ap :nth-of-type(odd)", ["google", "code1", "anchor1", "mark"] );
t( "Nth-of-type(-n+2)", "#qunit-fixture > :nth-of-type(-n+2)", ["firstp", "ap", "foo", "name+value", "firstUL", "empty", "form", "floatTest", "iframe", "lengthtest", "table", "moretests"] );
});

test("pseudo - nth-last-of-type", function() {
expect( 9 );
t( "Nth-last-of-type(-1)", ":nth-last-of-type(-1)", [] );
t( "Nth-last-of-type(3)", "#ap :nth-last-of-type(3)", ["google"] );
t( "Nth-last-of-type(n)", "#ap :nth-last-of-type(n)", ["google", "groups", "code1", "anchor1", "mark"] );
t( "Nth-last-of-type(0n+3)", "#ap :nth-last-of-type(0n+3)", ["google"] );
t( "Nth-last-of-type(2n)", "#ap :nth-last-of-type(2n)", ["groups"] );
t( "Nth-last-of-type(even)", "#ap :nth-last-of-type(even)", ["groups"] );
t( "Nth-last-of-type(2n+1)", "#ap :nth-last-of-type(2n+1)", ["google", "code1", "anchor1", "mark"] );
t( "Nth-last-of-type(odd)", "#ap :nth-last-of-type(odd)", ["google", "code1", "anchor1", "mark"] );
t( "Nth-last-of-type(-n+2)", "#qunit-fixture > :nth-last-of-type(-n+2)", ["ap", "name+value", "first", "firstUL", "empty", "floatTest", "iframe", "table", "name-tests", "testForm", "liveHandlerOrder", "siblingTest"] );
});

test("pseudo - misc", function() {