Skip to main content

Bug Tracker

Side navigation

#512 closed feature (invalid)

Opened December 15, 2006 06:57PM UTC

Closed January 02, 2007 05:57PM UTC

Last modified June 20, 2007 02:13AM UTC

Document functions on destructive methods

Reported by: Dave Owned by:
Priority: minor Milestone:
Component: docs Version:
Keywords: Cc:
Blocked by: Blocking:

Here is my attempt to document them.

All destructive methods can optionally take one or two trailing function arguments, e.g., .find("div", fn, fn2).

If no functions are provided, the chain receives the modified list of nodes changed by the destructive method.

If there is one trailing function arg, it does .each(fn) with the changed set but returns the original list of nodes to the chain.

If there are two trailing function args, the first (fn) is treated as above. However, if the changed set was empty (and thus fn was never called) it does .each(fn2) with the original set and also returns the original set for chaining.

The effect is similar to an if-then-else, and lets you perform operations on sets of elements without disturbing the original elements in the chain.

Attachments (0)
Change History (1)

Changed January 02, 2007 05:57PM UTC by john comment:1

resolution: → invalid
status: newclosed

Ok, I've just finished removing the optional functions to the destructive methods. (and so, pushStack is now gone too) This is kind of a moot point, then.