« Return to Thread: Change href of external links

Re: Change href of external links

by Jonathan Sharp :: Rate this Message:

Reply to Author | View in Thread

On 12/14/06, Dave Methvin <dave.methvin@...> wrote:
Uh oh, I know what it is. It's a bug in pushStack.
 
If the last arg to pushStack is a function, it does .each(fn) with the filtered set but returns the original set. If there are two trailing function args, the first is treated as above. However, if the filtered set returned nothing (and thus fn was never called) it does .each(fn2) with the original set. Kind of like an if-then-else. It's never been documented but I think it will be eventually.
 
I think this should fix it:
 
 pushStack: function(a,args) {
  var fn = args && args.length > 1 && args[args.length-1];
  var fn2 = args && args.length > 2 && args[args.length-2];

Has this been fixed in svn or has a bug ticket been opened?

Cheers,
-js

_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

 « Return to Thread: Change href of external links

LightInTheBox - Buy quality products at wholesale price