refactor: make accessibilitySupportEnabled a property on app (#17362)
* refactor: make accessibilitySupport a prop on app * fix docs * update spec
This commit is contained in:
parent
11699d8611
commit
9c3cb55ef2
8 changed files with 56 additions and 36 deletions
|
@ -38,8 +38,6 @@ Object.assign(app, {
|
|||
}
|
||||
})
|
||||
|
||||
app.getFileIcon = deprecate.promisify(app.getFileIcon)
|
||||
|
||||
// we define this here because it'd be overly complicated to
|
||||
// do in native land
|
||||
Object.defineProperty(app, 'applicationMenu', {
|
||||
|
@ -76,6 +74,12 @@ for (const name of events) {
|
|||
})
|
||||
}
|
||||
|
||||
// Function Deprecations
|
||||
app.getFileIcon = deprecate.promisify(app.getFileIcon)
|
||||
|
||||
// Property Deprecations
|
||||
deprecate.fnToProperty(app, 'accessibilitySupportEnabled', '_isAccessibilitySupportEnabled', '_setAccessibilitySupportEnabled')
|
||||
|
||||
// Wrappers for native classes.
|
||||
const { DownloadItem } = process.electronBinding('download_item')
|
||||
Object.setPrototypeOf(DownloadItem.prototype, EventEmitter.prototype)
|
||||
|
|
|
@ -55,25 +55,18 @@ const deprecate: ElectronInternal.DeprecationUtil = {
|
|||
})
|
||||
},
|
||||
|
||||
// deprecate a getter/setter function in favor of a property
|
||||
fnToProperty: <A extends Function, B extends Function>(propName: string, getterFn: A, setterFn: B) => {
|
||||
const getterName = getterFn.name || 'function'
|
||||
const setterName = setterFn.name || 'function'
|
||||
|
||||
const warnGetter = warnOnce(`${getterName} function`, `${propName} property `)
|
||||
const warnSetter = warnOnce(`${setterName} function`, `${propName} property `)
|
||||
|
||||
const deprecatedGetter: unknown = function (this: any) {
|
||||
warnGetter()
|
||||
getterFn.apply(this, arguments)
|
||||
// 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) => {
|
||||
const warn = warnOnce(oldName, newName)
|
||||
return (...args: any) => {
|
||||
warn()
|
||||
return obj[key](...args)
|
||||
}
|
||||
}
|
||||
|
||||
const deprecatedSetter: unknown = function (this: any) {
|
||||
warnSetter()
|
||||
setterFn.apply(this, arguments)
|
||||
}
|
||||
|
||||
return [deprecatedGetter as A, deprecatedSetter as B]
|
||||
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`)
|
||||
},
|
||||
|
||||
// remove a property with no replacement
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue