This project is archived and is in readonly mode.

#283 ✓resolved

don't allow the $events[type] array to be modified while traversing it

Reported by JacobThornton | March 15th, 2010 @ 11:08 PM | in rc1

Currently you can remove a specific event function from an array while you're traversing it, which is prone to problems (I know this isn't allowed in java). Instead I was thinking maybe we should clone the $events[type] before beginning the iteration (i did it below with slice), seemed to help.

fireEvent: function(type, args, delay){

    type = Events.removeOn(type);
    if (!this.$events || !this.$events[type]) return this;
            //cloned here with slice
        fn.create({'bind': this, 'delay': delay, 'arguments': args})();
    }, this);
    return this;

Comments and changes to this ticket

  • deos

    deos June 24th, 2010 @ 02:04 PM

    confirmed, this caused me some trouble a while ago... nearly went crazy...
    this is quite important in my opinion, please fix it!

    the same bug is in More delegation

  • Arian

    Arian September 20th, 2010 @ 04:38 PM

    • Milestone set to rc1
    • State changed from “new” to “resolved”
    • Milestone order changed from “0” to “0”

    I think this is fixed in 1.3. Could you confirm with a jsfiddle?

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The MooTools Extensions

People watching this ticket