Expression/Selector question...

Expression/Selector question...


I sent this message to the Dev list the other day, but perhaps (based on the
lack of feedback) that was the wrong list to send the inquiry too.
--------------------------------------------------------------------------
One thing that I've noticed is that the "expr" attribute is pretty
inconsistent across methods (such as filter, find, parents, parent, etc.)
The documentation is very vague about what an "expression" is, other than it
just being a selector. However I would assume a valid expression for one
method would be valid for all methods, but I've noticed that an HTML element
or jQuery object is only a valid expression in some methods (like the find()
method.)
For example:
$li = $("li");
// returns the first matches for $li
$("body > ul > li").find($li[0]);
// this actually errors with a "t.substring is not a function" error
$("body > ul > li").filter($li[0]);
// I would expect this to only return the element which is the first $li,
// but instead it ignores the expression altogether and returns all parents
$("li[rel=45]").parents($li[0]);
Shouldn't "expressions" work the same across all methods?
Right now I'm having to use this to find only the explicit parent:
$el.parents().filter(function (){ return this === $parent[0]; });
However, if parents() worked like find() I would be able to do:
$el.parents($parent[0]);
(Before you say "Why not just use $parent?", it's because I'm checking to
see if an element is a descendant of a cached jQuery element.)
-Dan