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
element would be valid for all elements, but I've noticed that an HTML
element is only a valid expression in 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 child of a specific element.)

-Dan

Reply via email to