element.removeEvents fails to remove delegated events on focus #2407

Closed
DimitarChristoff opened this Issue Aug 14, 2012 · 5 comments

Projects

None yet

4 participants

@DimitarChristoff
MooTools member

this is breaking now, used to work in 1.3.2

var form = document.getElement('form');

// store focus for trying
var boundFocus = function() {
    console.log('pocus');
    // unbind it. both fail.
    console.log(form.retrieve('events'));
    form.removeEvents('focus:relay(input,select,textarea)');
    form.removeEvent('focus:relay(input,select,textarea)', boundFocus);
    console.log(form.retrieve('events'));
};

form.addEvent('focus:relay(input,select,textarea)', boundFocus);

on a simple dom:

<form>
    <input />
</form>

focus once. blur. focus again. expected: no console output.

http://jsfiddle.net/qSCvc/3/

and on 1.3.2 via -more - as expected. http://jsfiddle.net/qSCvc/4/

@DimitarChristoff
MooTools member

seems related to focus. for example, this works on keypress -> http://jsfiddle.net/qSCvc/5/ so it may be down to event types...

@dalevink

It seems to be a browser specific issue.

I'm getting the same (unexpected) result in Windows IE9 – but works as expected on IE8 and Chrome on the Mac.

@DimitarChristoff
MooTools member

in my chrome on osx, it fails to remove the focus:relay event - though I originally discovered it on Firefox nightly (Aurora).

@dalevink

Sorry you're right – it's an issue on Chrome etc for me too… and yes, it seems to be isolated to focus:relay.

@simon-at-fugu

They have forgot to add the capture mod.
Change in mootools Element.Delegation.js on line 178

return removeEvent.call(this, type, delegator);

to

return removeEvent.call(this, type, delegator, _map.capture);

it seems, it's new in the browser that they handle the capture mods different....

@arian arian closed this in 1b80dd4 Dec 19, 2012
@arian arian added a commit that referenced this issue Dec 19, 2012
@arian arian Fixes #2407 - Merge branch 'fix-2407' edef4ae
@ibolmo ibolmo added a commit to ibolmo/mootools-core that referenced this issue Feb 16, 2014
@simon-at-fugu simon-at-fugu Fixes #2407 - add capture info to removeEvent 0c064bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment