[MAGNOLIA-469] Unfriendly JavaScript Array Looping Created: 01/Jul/05  Updated: 20/Jul/05  Resolved: 20/Jul/05

Status: Closed
Project: Magnolia
Component/s: admininterface
Affects Version/s: 2.1 Final
Fix Version/s: 2.1 Final

Type: Bug Priority: Major
Reporter: Bruce Collier Assignee: Boris Kraft
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

JavaScript (in all browsers)


Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

We are integrating our own JavaScript effects into a Magnolia website, but finding that the Magnolia gui admin JavaScript is being broken when we do so.

Many third party JavaScript libraries implement features by adding 'prototype' methods to inbuilt JavaScript objects. For example, adding the 'push' method to the Array object for browsers that don't have it.

A side effect of adding prototype methods to the array object is that the new method is then visible when the array is iterated via a "for (i in arr)" loop. It is therefore advisable to avoid that style of loop, but to use "for (i=0; i<arr.length; i++)" instead.

I've found one place this needs to be fixed, namely on line 343 in:
/admindocroot/js/general.js

Old line:
for (var elem in qs)

Fixed version:
for (var elem=0; elem<qs.length; elem++)



 Comments   
Comment by Fabrizio Giustina [ 17/Jul/05 ]

fixed in svn, thanks

Comment by Boris Kraft [ 20/Jul/05 ]

Change fix version to RC2

Generated at Mon Feb 12 03:17:44 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.