wip: add private api compat flag
This commit is contained in:
parent
6f8fe4eac9
commit
7b37f78dc9
@ -58,7 +58,9 @@ export const enum DeprecationTypes {
|
|||||||
|
|
||||||
RENDER_FUNCTION = 'RENDER_FUNCTION',
|
RENDER_FUNCTION = 'RENDER_FUNCTION',
|
||||||
|
|
||||||
FILTERS = 'FILTERS'
|
FILTERS = 'FILTERS',
|
||||||
|
|
||||||
|
PRIVATE_APIS = 'PRIVATE_APIS'
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeprecationData = {
|
type DeprecationData = {
|
||||||
@ -404,6 +406,13 @@ const deprecationData: Record<DeprecationTypes, DeprecationData> = {
|
|||||||
`The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
|
`The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
|
||||||
`Use method calls or computed properties instead.`,
|
`Use method calls or computed properties instead.`,
|
||||||
link: `https://v3.vuejs.org/guide/migration/filters.html`
|
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' }.`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,40 +91,44 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) {
|
|||||||
$off: i => off.bind(null, i),
|
$off: i => off.bind(null, i),
|
||||||
|
|
||||||
$children: getCompatChildren,
|
$children: getCompatChildren,
|
||||||
$listeners: getCompatListeners,
|
$listeners: getCompatListeners
|
||||||
|
|
||||||
$vnode: i => i.vnode,
|
|
||||||
|
|
||||||
// inject addtional properties into $options for compat
|
|
||||||
$options: i => {
|
|
||||||
let res = resolveMergedOptions(i)
|
|
||||||
if (res === i.type) res = i.type.__merged = extend({}, res)
|
|
||||||
res.parent = i.proxy!.$parent
|
|
||||||
res.propsData = i.vnode.props
|
|
||||||
return res
|
|
||||||
},
|
|
||||||
|
|
||||||
// v2 render helpers
|
|
||||||
$createElement: () => compatH,
|
|
||||||
_self: i => i.proxy,
|
|
||||||
_uid: i => i.uid,
|
|
||||||
_c: () => compatH,
|
|
||||||
_o: () => legacyMarkOnce,
|
|
||||||
_n: () => toNumber,
|
|
||||||
_s: () => toDisplayString,
|
|
||||||
_l: () => renderList,
|
|
||||||
_t: i => legacyRenderSlot.bind(null, i),
|
|
||||||
_q: () => looseEqual,
|
|
||||||
_i: () => looseIndexOf,
|
|
||||||
_m: i => legacyRenderStatic.bind(null, i),
|
|
||||||
_f: () => resolveFilter,
|
|
||||||
_k: i => legacyCheckKeyCodes.bind(null, i),
|
|
||||||
_b: () => legacyBindObjectProps,
|
|
||||||
_v: () => createTextVNode,
|
|
||||||
_e: () => createCommentVNode,
|
|
||||||
_u: () => legacyresolveScopedSlots,
|
|
||||||
_g: () => legacyBindObjectListeners,
|
|
||||||
_d: () => legacyBindDynamicKeys,
|
|
||||||
_p: () => legacyPrependModifier
|
|
||||||
} as PublicPropertiesMap)
|
} as PublicPropertiesMap)
|
||||||
|
|
||||||
|
if (isCompatEnabled(DeprecationTypes.PRIVATE_APIS, null)) {
|
||||||
|
extend(map, {
|
||||||
|
$vnode: i => i.vnode,
|
||||||
|
|
||||||
|
// inject addtional properties into $options for compat
|
||||||
|
$options: i => {
|
||||||
|
let res = resolveMergedOptions(i)
|
||||||
|
if (res === i.type) res = i.type.__merged = extend({}, res)
|
||||||
|
res.parent = i.proxy!.$parent
|
||||||
|
res.propsData = i.vnode.props
|
||||||
|
return res
|
||||||
|
},
|
||||||
|
|
||||||
|
// v2 render helpers
|
||||||
|
$createElement: () => compatH,
|
||||||
|
_self: i => i.proxy,
|
||||||
|
_uid: i => i.uid,
|
||||||
|
_c: () => compatH,
|
||||||
|
_o: () => legacyMarkOnce,
|
||||||
|
_n: () => toNumber,
|
||||||
|
_s: () => toDisplayString,
|
||||||
|
_l: () => renderList,
|
||||||
|
_t: i => legacyRenderSlot.bind(null, i),
|
||||||
|
_q: () => looseEqual,
|
||||||
|
_i: () => looseIndexOf,
|
||||||
|
_m: i => legacyRenderStatic.bind(null, i),
|
||||||
|
_f: () => resolveFilter,
|
||||||
|
_k: i => legacyCheckKeyCodes.bind(null, i),
|
||||||
|
_b: () => legacyBindObjectProps,
|
||||||
|
_v: () => createTextVNode,
|
||||||
|
_e: () => createCommentVNode,
|
||||||
|
_u: () => legacyresolveScopedSlots,
|
||||||
|
_g: () => legacyBindObjectListeners,
|
||||||
|
_d: () => legacyBindDynamicKeys,
|
||||||
|
_p: () => legacyPrependModifier
|
||||||
|
} as PublicPropertiesMap)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,11 @@ function convertLegacySlots(vnode: VNode): VNode {
|
|||||||
|
|
||||||
export function defineLegacyVNodeProperties(vnode: VNode) {
|
export function defineLegacyVNodeProperties(vnode: VNode) {
|
||||||
if (
|
if (
|
||||||
isCompatEnabled(DeprecationTypes.RENDER_FUNCTION, currentRenderingInstance)
|
isCompatEnabled(
|
||||||
|
DeprecationTypes.RENDER_FUNCTION,
|
||||||
|
currentRenderingInstance
|
||||||
|
) &&
|
||||||
|
isCompatEnabled(DeprecationTypes.PRIVATE_APIS, currentRenderingInstance)
|
||||||
) {
|
) {
|
||||||
const context = currentRenderingInstance
|
const context = currentRenderingInstance
|
||||||
const getInstance = () => vnode.component && vnode.component.proxy
|
const getInstance = () => vnode.component && vnode.component.proxy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user