Merge pull request #5617 from electron/dont-return-from-on-functions

Remove returns from event listeners
This commit is contained in:
Cheng Zhao 2016-05-20 00:26:29 +00:00
commit 4193fb1742
15 changed files with 34 additions and 36 deletions

View file

@ -59,8 +59,7 @@ deprecate.property = function (object, property, method) {
// Deprecate an event.
deprecate.event = function (emitter, oldName, newName, fn) {
var warned
warned = false
var warned = false
return emitter.on(newName, function (...args) {
// there is listeners for old API.
if (this.listenerCount(oldName) > 0) {
@ -69,9 +68,9 @@ deprecate.event = function (emitter, oldName, newName, fn) {
deprecate.warn("'" + oldName + "' event", "'" + newName + "' event")
}
if (fn != null) {
return fn.apply(this, arguments)
fn.apply(this, arguments)
} else {
return this.emit.apply(this, [oldName].concat(args))
this.emit.apply(this, [oldName].concat(args))
}
}
})