Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#512 closed feature (invalid)

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.

Change History (1)

comment:1 Changed 16 years ago by john

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.

Note: See TracTickets for help on using tickets.