Deprecate did-get-response-details and did-get-redirect-request (#12615)
* Deprecate webContents events did-get-response-details and did-get-redirect-request. * Update guest view files * Update webview tag docs and update specs * Update deprecate.event function * Update comment * Update more * Update documentation for other deprecated event
This commit is contained in:
parent
975964f9f0
commit
2579071b98
10 changed files with 47 additions and 37 deletions
|
@ -46,6 +46,27 @@ deprecate.log = (message) => {
|
|||
}
|
||||
}
|
||||
|
||||
// Deprecate an event.
|
||||
deprecate.event = (emitter, oldName, newName) => {
|
||||
let warned = false
|
||||
return emitter.on(newName, function (...args) {
|
||||
// There are no listeners for this event
|
||||
if (this.listenerCount(oldName) === 0) { return }
|
||||
// noDeprecation set or if user has already been warned
|
||||
if (warned || process.noDeprecation) { return }
|
||||
warned = true
|
||||
const isInternalEvent = newName.startsWith('-')
|
||||
if (isInternalEvent) {
|
||||
// The event cannot be use anymore. Log that.
|
||||
deprecate.log(`'${oldName}' event has been deprecated.`)
|
||||
} else {
|
||||
// The event has a new name now. Warn with that.
|
||||
deprecate.warn(`'${oldName}' event`, `'${newName}' event`)
|
||||
}
|
||||
this.emit(oldName, ...args)
|
||||
})
|
||||
}
|
||||
|
||||
deprecate.setHandler = (handler) => {
|
||||
deprecationHandler = handler
|
||||
}
|
||||
|
@ -81,22 +102,5 @@ deprecate.getHandler = () => deprecationHandler
|
|||
// })
|
||||
// }
|
||||
//
|
||||
// // Deprecate an event.
|
||||
// deprecate.event = (emitter, oldName, newName, fn) => {
|
||||
// let warned = false
|
||||
// return emitter.on(newName, function (...args) {
|
||||
// if (this.listenerCount(oldName) > 0) {
|
||||
// if (!(warned || process.noDeprecation)) {
|
||||
// warned = true
|
||||
// deprecate.warn(`'${oldName}' event`, `'${newName}' event`)
|
||||
// }
|
||||
// if (fn != null) {
|
||||
// fn.apply(this, arguments)
|
||||
// } else {
|
||||
// this.emit.apply(this, [oldName].concat(args))
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
module.exports = deprecate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue