findExclude(), a descending traversal method with functionality similar to parentsUntil

findExclude(), a descending traversal method with functionality similar to parentsUntil

Hello, first time contributor looking for feedback.

I ran into some issues where selectors were not the right tool for filtering nested elements and noticed a few cases of this around the internet. Primarily I see this in situations where people use $( selector ).each() for things like:
  • Search within a container class which may have the same type of container nested within, as in my example with "Messages" - for form message threads.


  • Searching by tag with nested ul/ol/table when each depth is meant to be a specific, contained view


  • Any time descendants should be searched relative to a starting element, repeatedly nesting CSS selectors have a greater chance of causing a conflicts

After exhausting my knowledge of selector magic and seeking advice from others, I started seeking out any mention of 'findUntil'. Eventually I came to the conclusion that find should continue beyond the "Until" because finds have a widening scope unlike the narrowing of parentsUntil or linear nature of siblingsUntil/nextUntil/prevUntil




So I ended up writing a plugin as lightweight and similar in functionality as I could. The name is nothing of great importance, but I called it findExclude as it excludes branches based on a mask selector during recursion over children. This and the above mentioned reasoning that findUntil would be slightly misleading; findUntil should just hault all searching on finding the selector.


Since I already need this as a plugin I have taken a draft attempt at including it here


I'd like any feedback regarding it's appropriateness and the appropriateness of the implementation. I'd like to get the code as close to the coding style within traversing.js as possible.


Aside of this, are there any resources / documentation on getting started writing the unit tests for jQuery? 


Thanks for any feedback.
Update: feature was closed

-Garet


















    • Topic Participants

    • garet