wikimedia-gadgets / twinkle

The English Wikipedia twinkle javascript helper
http://en.wikipedia.org/wiki/Wikipedia:Twinkle
Other
135 stars 148 forks source link

Do not use indexOf on arrays (breaks IE<9) #67

Closed ghost closed 12 years ago

ghost commented 12 years ago

Considering that IE<9 doesn't have an .indexOf() function for Array, could you replace all its uses by $.inArray?

On "morebits.js" there are two functions using indexOf on arrays. The code result.indexOf( current ) === -1 from Array.prototype.uniq could be changed to $.inArray( current, result ) === -1

Analogously, the code uniques.indexOf( current ) === -1 from Array.prototype.dups could be changed to $.inArray( current, uniques ) === -1

For more info, see:

ghost commented 12 years ago

Er... I just found another function using indexOf in the same js file. Somewhere in Wikipedia.page there is the code if (['recreate', 'createonly', 'nocreate'].indexOf(ctx.createOption) !== -1) { which could be changed to if ( $.inArray( ctx.createOption, ['recreate', 'createonly', 'nocreate'] ) !== -1) {

atlight commented 12 years ago

We do not plan to support IE <8. Upgrade to IE 9 if using Windows Vista or Windows 7, or use an alternative browser on earlier versions of Windows.