Hi,

I am using the Prototype javascript library (http://prototype.conio.net)
which, among other cool stuff, adds methods and properties to standard
JavaScript objects. This is all find and dandy, unless someone tries
something like this:

var myArray = new Array('a', 'b', 'c', 'd', 'e');
for(letter in myArray){
        doSomething(letter);
}

The problem is that Prototype has added a whole host of properties
(mostly methods) to Array, so the loop cycles through these as well,
almost certainly with crashing results. 

Such is the case in DatePicker.js, formatDate(): 

[where bits is an array of date format chunks ('d', 'dd', 'm', 'mm' and
so on)]:

for (sect in bits) {
        /* The nifty regex... */
}

I fixed this locally by doing this:

var allowedCombinations = "ddddmmmmyyyy";

for(sect in bits){
        if(allowedCombinations.indexOf(sect.toLowerCase()) != -1){
                /* do the nifty regex... */
        }
}

I am sure there are better ways of doing this, but is there any chance
of getting something similar into the tapestry code? Javascript is a
dynamic language and there is nothing wrong with adding properties to
classes, so it seems unwise to rely on this sort of iterator.

Best wishes

John

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to