wip: filters compat
This commit is contained in:
@@ -56,7 +56,9 @@ export const enum DeprecationTypes {
|
||||
COMPONENT_FUNCTIONAL = 'COMPONENT_FUNCTIONAL',
|
||||
COMPONENT_V_MODEL = 'COMPONENT_V_MODEL',
|
||||
|
||||
RENDER_FUNCTION = 'RENDER_FUNCTION'
|
||||
RENDER_FUNCTION = 'RENDER_FUNCTION',
|
||||
|
||||
FILTERS = 'FILTERS'
|
||||
}
|
||||
|
||||
type DeprecationData = {
|
||||
@@ -392,6 +394,14 @@ const deprecationData: Record<DeprecationTypes, DeprecationData> = {
|
||||
}: false })\n` +
|
||||
`\n (This can also be done per-component via the "compatConfig" option.)`,
|
||||
link: `https://v3.vuejs.org/guide/migration/render-function-api.html`
|
||||
},
|
||||
|
||||
[DeprecationTypes.FILTERS]: {
|
||||
message:
|
||||
`filters have been removed in Vue 3. ` +
|
||||
`The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
|
||||
`Use method calls or computed properties instead.`,
|
||||
link: `https://v3.vuejs.org/guide/migration/filters.html`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
packages/runtime-core/src/compat/filter.ts
Normal file
18
packages/runtime-core/src/compat/filter.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { App, AppContext } from '../apiCreateApp'
|
||||
import { warn } from '../warning'
|
||||
import { assertCompatEnabled, DeprecationTypes } from './compatConfig'
|
||||
|
||||
export function installGlobalFilterMethod(app: App, context: AppContext) {
|
||||
context.filters = {}
|
||||
app.filter = (name: string, filter?: Function): any => {
|
||||
assertCompatEnabled(DeprecationTypes.FILTERS, null)
|
||||
if (!filter) {
|
||||
return context.filters![name]
|
||||
}
|
||||
if (__DEV__ && context.filters![name]) {
|
||||
warn(`Filter "${name}" has already been registered.`)
|
||||
}
|
||||
context.filters![name] = filter
|
||||
return app
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user