Ticket #136 (closed defect: fixed)
Non-"Standard" implementation of Array.indexOf
| Reported by: | UdoBorkowski | Owned by: | MartinBudden |
|---|---|---|---|
| Priority: | critical | Milestone: | 2.1 |
| Component: | core | Version: | |
| Severity: | critical | Keywords: | |
| Cc: |
Description
Currently Array.prototype.indexOf is implemented this way
if(!Array.indexOf) {
Array.prototype.indexOf = function(item)
{
for(var i=0; i<this.length; i++)
if(this[i] == item)
return i;
return -1;
}}
With this code the "browser implementation" of Array...indexOf will be used when provided by the browser. This may lead to inconsistencies since according to developer.mozilla.org the "standard" semantic for Array.prototype.indexOf is different.
So either we remove the "if" and always use "our" implementation or provide a compatible implementation. Necessary changes include:
- compare using === (this is a critical change, since it changes our semantic)
- support optional fromIndex parameter (as documented here. Not critical, as long as we (and plugin developer) don't use it)
Change History
Note: See
TracTickets for help on using
tickets.
