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 ++ [EMAIL PROTECTED]

http://ipaction.org/ -- defend your rights to fair use
--- /home/kitchen/code/vendor/scriptaculous/prototype.js	2006-04-27 00:38:15.000000000 -0700
+++ prototype.js	2006-04-28 15:45:04.000000000 -0700
@@ -561,10 +561,10 @@
 
   _each: function(iterator) {
     var value = this.start;
-    do {
+    while (this.include(value)) {
       iterator(value);
       value = value.succ();
-    } while (this.include(value));
+    } 
   },
 
   include: function(value) {

Attachment: pgpKQblvnESgI.pgp
Description: PGP signature

_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to