Opened 17 years ago

Closed 16 years ago

#940 closed Bug (invalid)

Array prototype extensions breaks plugin code that uses "for(var i in <Array object>)"

Reported by: Paul Vrugt Owned by:
Priority: Normal Milestone:
Component: General Version: FCKeditor 2.4.3
Keywords: Cc:

Description

Instead of creating a new array object, or expanding the static Array object, the fckeditor messes with the standard array prototype. This results in the following problem:

suppose i do this in a plugin:

var objArray = new Array();
objArray['key1'] = 'value1';
objArray['key2'] = 'value2';

for(var strKey in objArray)

alert(objArray[strKey]);

i wanted to get all values from the array, but instead, i get all values + 2 function objects, since the fckEditor added AddItem and IndexOf to the array prototype.

Change History (1)

comment:1 Changed 16 years ago by Frederico Caldeira Knabben

Keywords: Array Prototype IndexOf AddItem removed
Resolution: invalid
Status: newclosed

You are wrongly using an array in your sample. You should use and Object instead:

var objArray = new Object();
objArray['key1'] = 'value1';
objArray['key2'] = 'value2';

for(var strKey in objArray)
    alert(objArray[strKey]);

In this case you will not have problems.

In any case, it is already part of our plans to avoid touching native objects.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy