refactor: convert browser window state fns to props (#18618)
This commit is contained in:
parent
164cc43440
commit
a0b1f4fe0b
10 changed files with 260 additions and 60 deletions
|
@ -57,17 +57,18 @@ const deprecate: ElectronInternal.DeprecationUtil = {
|
|||
},
|
||||
|
||||
// deprecate a getter/setter function pair in favor of a property
|
||||
fnToProperty: (module: any, prop: string, getter: string, setter: string) => {
|
||||
const withWarnOnce = (obj: any, key: any, oldName: string, newName: string) => {
|
||||
fnToProperty: (prototype: any, prop: string, getter: string, setter: string) => {
|
||||
const withWarnOnce = function (obj: any, key: any, oldName: string, newName: string) {
|
||||
const warn = warnOnce(oldName, newName)
|
||||
return (...args: any) => {
|
||||
const method = obj[key]
|
||||
return function (this: any, ...args: any) {
|
||||
warn()
|
||||
return obj[key](...args)
|
||||
return method.apply(this, args)
|
||||
}
|
||||
}
|
||||
|
||||
module[getter.substr(1)] = withWarnOnce(module, getter, `${getter.substr(1)} function`, `${prop} property`)
|
||||
module[setter.substr(1)] = withWarnOnce(module, setter, `${setter.substr(1)} function`, `${prop} property`)
|
||||
prototype[getter.substr(1)] = withWarnOnce(prototype, getter, `${getter.substr(1)} function`, `${prop} property`)
|
||||
prototype[setter.substr(1)] = withWarnOnce(prototype, setter, `${setter.substr(1)} function`, `${prop} property`)
|
||||
},
|
||||
|
||||
// remove a property with no replacement
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue