Brian,

I attempted to create something that would break, but I couldn't reproduce
any that would break.  Does this one break for you? (
http://mooshell.net/mWuQ6/1/)  If not could you create a mooshell that has
the problem that you specified?

--Perrin

On Mon, Dec 21, 2009 at 10:20 PM, Brian Ramsay <[email protected]>wrote:

> I am seeing a strange bug using MooTools' Hash object in Firefox.
>
> Many places in my code use $H(some_obj).each(function(stuff, key)
> { blah; }); and some of them are not working properly in Firefox
> 3.5.6.
>
> In Safari and Chrome everything ran fine, but Firefox would throw
> "TypeError: var key is not a function" on some tests in my unit test
> suite.  There were a few places that reliably failed, and another
> couple tests (using the same data as other passing tests) that only
> failed occasionally.
>
> I tracked the problem to the initialize method in Hash. If I edited
> the following code in the MooTools Hash definition
>
>    initialize: function(obj){        if ($type(obj) == 'hash') obj =
> $unlink(obj.getClean());
>        for (var key in obj) this[key] = obj[key];
>        return this;
>    }
>
> and removed the 'var' keyword, it all worked and the problem was
> resolved.
>
> Obviously I don't want to rely on a manual change in mootools as that
> would hamper my ability to upgrade, so I ended up replacing a few of
> the calls to $H() that I have in my script with a manual for( var key
> in my_obj) { }
>
> Example:
>        var keys = [];
>        for(var key in CharacterBase.classes) {
>            if(CharacterBase.classes.hasOwnProperty(key)) {
>                keys.push(key);
>            }
>        }
> instead of
>        var keys = $H(CharacterBase.classes).getKeys();
>
>
> Does anyone have any idea why this would be happening only in Firefox,
> and why it is seemingly sporadic?  The objects I am using are pretty
> straightforward.  Any clue what kind of bug in my own code could cause
> this behavior?
>
> Thanks,
> Brian
>

Reply via email to