wip: add private api compat flag

This commit is contained in:
Evan You 2021-04-22 17:50:49 -04:00
parent 6f8fe4eac9
commit 7b37f78dc9
3 changed files with 54 additions and 37 deletions

View File

@ -58,7 +58,9 @@ export const enum DeprecationTypes {
RENDER_FUNCTION = 'RENDER_FUNCTION',
FILTERS = 'FILTERS'
FILTERS = 'FILTERS',
PRIVATE_APIS = 'PRIVATE_APIS'
}
type DeprecationData = {
@ -404,6 +406,13 @@ const deprecationData: Record<DeprecationTypes, DeprecationData> = {
`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`
},
[DeprecationTypes.PRIVATE_APIS]: {
message: name =>
`"${name}" is a Vue 2 private API that no longer exists in Vue 3. ` +
`If you are seeing this warning only due to a dependency, you can ` +
`suppress this warning via { PRIVATE_APIS: 'supress-warning' }.`
}
}

View File

@ -91,8 +91,11 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) {
$off: i => off.bind(null, i),
$children: getCompatChildren,
$listeners: getCompatListeners,
$listeners: getCompatListeners
} as PublicPropertiesMap)
if (isCompatEnabled(DeprecationTypes.PRIVATE_APIS, null)) {
extend(map, {
$vnode: i => i.vnode,
// inject addtional properties into $options for compat
@ -127,4 +130,5 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) {
_d: () => legacyBindDynamicKeys,
_p: () => legacyPrependModifier
} as PublicPropertiesMap)
}
}

View File

@ -310,7 +310,11 @@ function convertLegacySlots(vnode: VNode): VNode {
export function defineLegacyVNodeProperties(vnode: VNode) {
if (
isCompatEnabled(DeprecationTypes.RENDER_FUNCTION, currentRenderingInstance)
isCompatEnabled(
DeprecationTypes.RENDER_FUNCTION,
currentRenderingInstance
) &&
isCompatEnabled(DeprecationTypes.PRIVATE_APIS, currentRenderingInstance)
) {
const context = currentRenderingInstance
const getInstance = () => vnode.component && vnode.component.proxy