X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=src%2Fselector%2FselectorTest.js;h=8200595c071ee6e5c21b784db1b6eb3556aec6d6;hb=d7a8794eb574a870fde9a8afdfd452e52804f65d;hp=5cd3b23e0e0cc5364aa44eea89b0caed61a3b590;hpb=af79bb1f255433d553d8d9dde0306cc340903c1a;p=jquery.git diff --git a/src/selector/selectorTest.js b/src/selector/selectorTest.js index 5cd3b23..8200595 100644 --- a/src/selector/selectorTest.js +++ b/src/selector/selectorTest.js @@ -1,13 +1,16 @@ module("selector"); test("element", function() { - expect(6); + expect(8); ok( $("*").size() >= 30, "Select all" ); t( "Element Selector", "div", ["main","foo"] ); t( "Element Selector", "body", ["body"] ); t( "Element Selector", "html", ["html"] ); t( "Parent Element", "div div", ["foo"] ); ok( $("param", "#object1").length == 2, "Object/param as context" ); + + ok( $("#length").length, '<input name="length"> cannot be found under IE, see #945' ); + ok( $("#lengthtest input").length, '<input name="length"> cannot be found under IE, see #945' ); }); test("broken", function() { @@ -22,7 +25,7 @@ test("broken", function() { }); test("id", function() { - expect(17); + expect(23); t( "ID Selector", "#body", ["body"] ); t( "ID Selector w/ Element", "body#body", ["body"] ); t( "ID Selector w/ Element", "ul#first", [] ); @@ -33,6 +36,13 @@ test("id", function() { t( "Descendant ID selector using UTF8", "div #台北", ["台北"] ); t( "Child ID selector using UTF8", "form > #台北", ["台北"] ); + t( "Escaped ID", "#foo\\:bar", ["foo:bar"] ); + t( "Escaped ID", "#test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); + t( "Descendant escaped ID", "div #foo\\:bar", ["foo:bar"] ); + t( "Descendant escaped ID", "div #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); + t( "Child escaped ID", "form > #foo\\:bar", ["foo:bar"] ); + t( "Child escaped ID", "form > #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); + t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] ); // bug #267 t( "ID Selector, not an ancestor ID", "#form #first", [] ); t( "ID Selector, not a child ID", "#form > #option1a", [] ); @@ -48,7 +58,7 @@ test("id", function() { }); test("class", function() { - expect(10); + expect(16); t( "Class Selector", ".blog", ["mark","simon"] ); t( "Class Selector", ".blog.link", ["simon"] ); t( "Class Selector w/ Element", "a.blog", ["mark","simon"] ); @@ -60,6 +70,13 @@ test("class", function() { t( "Class selector using UTF8", ".台北Táiběi, .台北", ["utf8class1","utf8class2"] ); t( "Descendant class selector using UTF8", "div .台北Táiběi", ["utf8class1"] ); t( "Child class selector using UTF8", "form > .台北Táiběi", ["utf8class1"] ); + + t( "Escaped Class", ".foo\\:bar", ["foo:bar"] ); + t( "Escaped Class", ".test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); + t( "Descendant scaped Class", "div .foo\\:bar", ["foo:bar"] ); + t( "Descendant scaped Class", "div .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); + t( "Child escaped Class", "form > .foo\\:bar", ["foo:bar"] ); + t( "Child escaped Class", "form > .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] ); }); test("multiple", function() { @@ -71,7 +88,7 @@ test("multiple", function() { }); test("child and adjacent", function() { - expect(14); + expect(22); t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] ); t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] ); t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] ); @@ -85,7 +102,18 @@ test("child and adjacent", function() { t( "Adjacent", "a+a", ["groups"] ); t( "Adjacent", "p + p", ["ap","en","sap"] ); t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] ); + t( "First Child", "p:first-child", ["firstp","sndp"] ); + t( "Nth Child", "p:nth-child(1)", ["firstp","sndp"] ); + t( "First Child, XPath", "p[1]", ["firstp","sndp"] ); + + t( "Last Child", "p:last-child", ["sap"] ); + t( "Last Child, XPath", "p[3]", ["sap"] ); + + t( "Nth-child", "#main form > *:nth-child(2)", ["text2"] ); + t( "Nth-child, XPath", "#main form > *[2]", ["text2"] ); + t( "Nth-child", "#main form > :nth-child(2)", ["text2"] ); + t( "Nth-child, XPath", "#main form > [2]", ["text2"] ); }); test("attributes", function() { @@ -118,7 +146,7 @@ test("attributes", function() { t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]); }); -test("pseudo (:) selctors", function() { +test("pseudo (:) selectors", function() { expect(30); t( "First Child", "p:first-child", ["firstp","sndp"] ); t( "Last Child", "p:last-child", ["sap"] ); @@ -174,4 +202,4 @@ test("basic xpath", function() { $("#foo").each(function() { isSet( $("/p", this).get(), q("sndp", "en", "sap"), "Check XPath context" ); }); -}); +}); \ No newline at end of file