Last active
August 29, 2015 14:05
-
-
Save giuseppeg/bf609a4bd86121e995fa to your computer and use it in GitHub Desktop.
unbind proxied event in FlightJS - patch idea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.off = function() { | |
var $element, type, proxiedTo, callback; | |
var lastIndex = arguments.length - 1, origin = arguments[lastIndex]; | |
if (typeof origin == 'function') { | |
callback = origin; | |
arguments[lastIndex] = undefined; | |
} | |
if (lastIndex == 1) { | |
type = arguments[0]; | |
proxiedTo = registry.findInstanceInfo(this).events.some(function (event) { | |
// this.off('event', 'proxy') | |
return event.type == type; | |
}); | |
// if this.off('.selector', 'event') | |
// we increase lastIndex so that we fall in the 1st case of the if below [1] | |
if (!proxiedTo) { | |
lastIndex += 1; | |
} | |
} | |
// [1] | |
if (lastIndex == 2) { | |
// this.off(selector, 'event', fn) | |
// this.off(selector, 'event', 'proxy') | |
// this.off(selector, 'event') | |
$element = $(arguments[0]); | |
type = arguments[1]; | |
// arguments[2] is undefined if origin was a fn (callback) | |
// or it is our 'proxied event name' string | |
proxiedTo = arguments[2]; | |
} else { | |
// this.off('event', fn) | |
// this.off('event', 'proxy') | |
// this.off('event') | |
$element = this.$node; | |
type = arguments[0]; | |
// arguments[1] is undefined if origin was a fn (callback) | |
// or it is our 'proxied event name' string | |
proxiedTo = arguments[1]; | |
} | |
/* ... */ | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment