Ticket #136 (closed defect: fixed)

Opened 7 years ago

Last modified 7 years ago

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

Changed 7 years ago by MartinBudden

  • owner changed from JeremyRuston to MartinBudden

Changed 7 years ago by MartinBudden

  • status changed from new to assigned

Changed 7 years ago by JeremyRuston

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in changeset:680

Note: See TracTickets for help on using tickets.