Added in the new .closest(Array) method, will be used to improve the performance of live filtering.

This commit is contained in:
jeresig 2009-12-02 19:05:51 -05:00
parent 62436f4b29
commit e534a310c7
2 changed files with 42 additions and 9 deletions

View file

@ -107,6 +107,17 @@ test("closest()", function() {
same( jq.closest("#nothiddendiv", document.body).get(), q("nothiddendiv"), "Context not reached." );
});
test("closest(Array)", function() {
expect(6);
same( jQuery("body").closest(["body"]), [{selector:"body", elem:document.body}], "closest([body])" );
same( jQuery("body").closest(["html"]), [{selector:"html", elem:document.documentElement}], "closest([html])" );
same( jQuery("body").closest(["div"]), [], "closest([div])" );
same( jQuery("#main").closest(["span,#html"]), [{selector:"span,#html", elem:document.documentElement}], "closest([span,#html])" );
same( jQuery("body").closest(["body","html"]), [{selector:"body", elem:document.body}, {selector:"html", elem:document.documentElement}], "closest([body, html])" );
same( jQuery("body").closest(["span","html"]), [{selector:"html", elem:document.documentElement}], "closest([body, html])" );
});
test("not(Selector)", function() {
expect(7);
equals( jQuery("#main > p#ap > a").not("#google").length, 2, "not('selector')" );