Another parameter to $(...).closest('...');?

Another parameter to $(...).closest('...');?


I have a function similar to the .closest method in jQuery inside of
my framework. I was wondering if it was a good idea to have .closest
accept am optional second argument (restriction) to it like my own.
In my framework I use pf.trace (tracing backwards through the dom)
almost precisely the same as .closest;
pf('#foo').click(function(e) {
var elm = pf.trace(e.target, 'li', this);
if(!elm) return;
...
});
The third argument is a restriction. You can basically read that as
"trace backwards through the dom starting at e.target and return the
first li tag found, don't return any node if you hit 'this'.
The third argument is a restriction so basically in a case like:
<ul>
<li>
<ul id="foo">
<li>...</li>
<ul>
<li>
</ul>
If you clicked on the ul#foo instead of the li inside of it (things
like that are quite possible after you've done styling) then just
using .closest('li') will return the parent li which you don't want.
Another argument could serve as a restriction to the check.