Skip to content

bad low level API call #366

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

Closed
boussou opened this issue Jul 21, 2014 · 2 comments
Closed

bad low level API call #366

boussou opened this issue Jul 21, 2014 · 2 comments

Comments

@boussou
Copy link

boussou commented Jul 21, 2014

(Not a big deal)
on vue/src/directives/on.js:

reset function should be :
reset: function () {
var el = this.iframeBind
? this.el.contentWindow
: this.el
this.handler && el.removeEventListener(this.arg, this.handler)
},

Added code is "this.handler && "
Reason: at init, call to removeEventListener() while this.handler is null
according to specs, calls must always have the handler
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.removeEventListener

This happens because in update() function " this.reset() " (line 4253) is called before this.handler (line 4256) is defined.

@yyx990803
Copy link
Member

Thanks, it's usually fine to call it with a null or undefined listener value, since the spec says:

Calling removeEventListener with arguments which do not identify any currently registered EventListener on the EventTarget has no effect.

But in this case checking for handler first does avoid an expensive removeEventListener call so this is still a good change.

@boussou
Copy link
Author

boussou commented Jul 21, 2014

Good. I am monitoring the event bindings so it is useful to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants