Stylish-Select
Stylish-Select copied to clipboard
Array.prototype.indexOf causes for..in on Array to have extra element in IE
I came across this the other day. Another developer was using for...in to loop through an Array. In IE, it would include the indexOf function as an item in the area. Very odd, but a pain to figure out.
Recreate: Include stylish select.
In another javascript file, after stylish select has been run, execute this code:
var arr = [1,2,3];
for(var i in arr){ alert(arr[i]); alert(typeof(arr[i])); }
Question: Do you need to add indexOf to the prototype, or could you just use the $.inArrray()? http://api.jquery.com/jQuery.inArray/
Any updates on this. I can submit a fix?
Or is this project pretty dead?
Not touched the project for a while, but you're welcome to submit a pr if you like.
On 16 December 2014 at 17:06, Ifiok Jr. [email protected] wrote:
Any updates on this. I can submit a fix?
Or is this project pretty dead?
Reply to this email directly or view it on GitHub https://github.com/scottdarby/Stylish-Select/issues/28#issuecomment-67193706 .
Also it's worth noting that that the indexOf prototype override in this plugin can dramatically affect other code. I had a problem today when some third-party JS (a widget) was relying on indexOf returning -1
when it can't find a given element in the array - the expected response.
However, this module (crazily) returns undefined
, completely borking the expected behaviour and resulting in broken widgets everywhere. Discontinued!