I''m using prototype 1.4.0 in a big web application I''ve been working on for months and today a bug was raised by one of our testers. After investigation it turns out that something done 0 times will actually fire once. So, for example, if I had (0).times( function(i) { alert(i); } ); it''d fire once rather than not at all. Is this a bug in prototype or the expected behaviour? Eifion
On Friday 28 April 2006 15:25, Eifion wrote:> I''m using prototype 1.4.0 in a big web application I''ve been working > on for months and today a bug was raised by one of our testers. After > investigation it turns out that something done 0 times will actually > fire once. So, for example, if I had > > (0).times( function(i) { alert(i); } ); > > it''d fire once rather than not at all. Is this a bug in prototype or > the expected behaviour?bug in prototype. Give me a few minutes and I''ll get you a patch :) -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org http://ipaction.org/ -- defend your rights to fair use _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On Friday 28 April 2006 15:37, Jeremy Kitchen wrote:> On Friday 28 April 2006 15:25, Eifion wrote: > > I''m using prototype 1.4.0 in a big web application I''ve been working > > on for months and today a bug was raised by one of our testers. After > > investigation it turns out that something done 0 times will actually > > fire once. So, for example, if I had > > > > (0).times( function(i) { alert(i); } ); > > > > it''d fire once rather than not at all. Is this a bug in prototype or > > the expected behaviour? > > bug in prototype. Give me a few minutes and I''ll get you a patch :)and here it is. The problem was because a do { } while() always runs at least once. So I changed it to a while() {} and it solved the problem. I have a test page here: http://edge.scriptkitchen.com:81/~kitchen/times.html -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org http://ipaction.org/ -- defend your rights to fair use _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Thanks a lot, Jeremy! Eifion On 28 Ebrill 2006, at 23:51, Jeremy Kitchen wrote:> On Friday 28 April 2006 15:37, Jeremy Kitchen wrote: >> On Friday 28 April 2006 15:25, Eifion wrote: >>> I''m using prototype 1.4.0 in a big web application I''ve been working >>> on for months and today a bug was raised by one of our testers. >>> After >>> investigation it turns out that something done 0 times will actually >>> fire once. So, for example, if I had >>> >>> (0).times( function(i) { alert(i); } ); >>> >>> it''d fire once rather than not at all. Is this a bug in prototype or >>> the expected behaviour? >> >> bug in prototype. Give me a few minutes and I''ll get you a patch :) > > and here it is. The problem was because a do { } while() always > runs at least > once. So I changed it to a while() {} and it solved the problem. > > I have a test page here: http://edge.scriptkitchen.com:81/~kitchen/ > times.html > > -Jeremy > > -- > Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org > > http://ipaction.org/ -- defend your rights to fair use > <prototype.js.zerotimes.patch> > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 4/29/06, Jeremy Kitchen <kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org> wrote:> > bug in prototype. Give me a few minutes and I''ll get you a patch :) > > and here it is. The problem was because a do { } while() always runs at least > once. So I changed it to a while() {} and it solved the problem.A patch for this bug was submitted over a month ago... http://dev.rubyonrails.org/ticket/4419