PDA

View Full Version : The remove function in Array.prototype



Sart
24 Nov 2010, 1:57 AM
Line 1045 in ext-base-debug.jsvar index = this.indexOf(o);In some cases we get "object doesn't support such property or method". Don't remember the exatct wording but it seems this "remove" is called on an objects which isn't an array. The problem most evidently manifests itself when ExtJs is used with Oracle Mapviewer - all sorts of miracles :) And this code is the same in both 3.2 and 3.3 versions.Mended this by enclosing indexOf into try/catch:var index = -1;try { index = this.indexOf(o);} catch (e) { index = -1;}if(index != -1){ this.splice(index, 1);}return this;Thank you,Igor

Condor
24 Nov 2010, 4:21 AM
Adding a try/catch will make the indexOf call significally slower.

Wouldn't it be better to figure out which code is calling indexOf on a non-array?