-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow event handlers registered with one() to be removed with off(). #659
Conversation
@@ -329,8 +329,10 @@ vjs.trigger = function(elem, event) { | |||
* @return {[type]} | |||
*/ | |||
vjs.one = function(elem, type, fn) { | |||
vjs.on(elem, type, function(){ | |||
var func = function(){ | |||
vjs.off(elem, type, arguments.callee); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while we're at it, can we get rid of arguments.callee
since it has been deprecated?
We should be able to just put func
in there instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that'd be good. Would there be an issue with the var func being assigned after the function is created?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be fine since the function gets called after func
has been defined.
For example:
var foo = function() {
console.log(foo.toString());
};
foo();
// function() { console.log(foo.toString()); }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks.
@delner Mind making that small change, and then I'll pull it in? |
Should be good to go; test worked fine on my fork. |
👍 |
Nice! |
Fixes #658