The point I am trying unsuccessfully to make is that the context
change will break existing code. It will make the specific context
required anytime raw nodes are used, which is probably the most common
"closest" usage pattern.

Instead of using the context, if a 2nd argument is added to the
method, it will not break any existing code, and it will be optional.

Maybe the solution could be a combination of the two? The argument
could be a boolean "useContext"?

$( event.target ).closest(".foo");

$( event.target, context ).closest(".bar",true);

On Jul 23, 2:21 pm, John Resig <jere...@gmail.com> wrote:
> > I have no specific use case in mind for that particular example. I was
> > thinking of the second "closest" argument would act like a break
> > statement rather than a search within context.
>
> > Still, If the context is used to limit the traversal of the closest
> > loop, how would you set the context of raw DOM nodes such that $
> > ( event.target ).closest(".foo"); was still useful?
>
> In that case you would do:
>
> $( event.target, someContainer ).closest(".foo");
>
> For example, if you didn't want to go beyond the body you could say:
>
> $( event.target, document.body ).closest(".foo");
>
> or if you don't want to go beyond some specific node (which you would
> probably want to cache):
>
> $( event.target, $(".bar")[0] ).closest(".foo");
>
> --John
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to