nmccready / angular-simple-logger

Basic logger with level logging which can also be independent.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

for in loop issues

fvanzile opened this issue · comments

the for in loop will loop on all array properties.
if some lib extends the javascript array like https://code.google.com/p/geoxml3/ adding properties
this causes issues

I am not sure how this is a problem as I am only using for in on _fns which is an array.

Is this a angular google maps problem?

Can you come up with an example for this problem.

Please make a plnkr

I can create a plnkr but it's a relatively simple description.

i am using http://angular-ui.github.io/angular-google-maps/#!/
thank you for doing this. this is working great. thank you.

i am using https://code.google.com/p/geoxml3/source/browse/branches/kmz/geoxml3.js
at line 1943 they are adding functions to an array.
Array.prototype.hasObject
Array.prototype.hasItemInObj

the for loop 'for (key in _fns) {' is then iterating all properties of the _fns array with is then also finding and iterating over the added functions hasObject and hasItemInObj which was added to the array. this then is causing/hitting exceptions in the 'for (key in _fns) {' loop. since the loop is finding (iterating over) these unexpected items.

what i had to do was change all
for (key in _fns) {
to
for (var j = 0; j < _fns.length; ++j) {
for a safer loop iterator.

Is this cause your tossing in a custom logger? Cause the iterator is only over the logger functions which are locked down to an array. Anyway I need an example.

Closing until more feedback.