From: Evan You Date: Tue, 4 May 2021 22:20:14 +0000 (-0400) Subject: wip: enable private vnode properties even for built-ins X-Git-Tag: v3.1.0-beta.1~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e6a76e587d7434f56459a6cb9a652f536dc663a;p=thirdparty%2Fvuejs%2Fcore.git wip: enable private vnode properties even for built-ins --- diff --git a/packages/runtime-core/src/compat/compatConfig.ts b/packages/runtime-core/src/compat/compatConfig.ts index d715d97040..cbff8c7856 100644 --- a/packages/runtime-core/src/compat/compatConfig.ts +++ b/packages/runtime-core/src/compat/compatConfig.ts @@ -566,10 +566,11 @@ export function getCompatConfigForKey( export function isCompatEnabled( key: DeprecationTypes, - instance: ComponentInternalInstance | null + instance: ComponentInternalInstance | null, + enableForBuiltIn = false ): boolean { // skip compat for built-in components - if (instance && instance.type.__isBuiltIn) { + if (!enableForBuiltIn && instance && instance.type.__isBuiltIn) { return false } diff --git a/packages/runtime-core/src/compat/renderFn.ts b/packages/runtime-core/src/compat/renderFn.ts index ba67cd3663..af8e78a337 100644 --- a/packages/runtime-core/src/compat/renderFn.ts +++ b/packages/runtime-core/src/compat/renderFn.ts @@ -307,16 +307,21 @@ export function defineLegacyVNodeProperties(vnode: VNode) { if ( isCompatEnabled( DeprecationTypes.RENDER_FUNCTION, - currentRenderingInstance + currentRenderingInstance, + true /* enable for built-ins */ ) && - isCompatEnabled(DeprecationTypes.PRIVATE_APIS, currentRenderingInstance) + isCompatEnabled( + DeprecationTypes.PRIVATE_APIS, + currentRenderingInstance, + true /* enable for built-ins */ + ) ) { const context = currentRenderingInstance const getInstance = () => vnode.component && vnode.component.proxy let componentOptions: any Object.defineProperties(vnode, { tag: { get: () => vnode.type }, - data: { get: () => vnode.props, set: p => (vnode.props = p) }, + data: { get: () => vnode.props || {}, set: p => (vnode.props = p) }, elm: { get: () => vnode.el }, componentInstance: { get: getInstance }, child: { get: getInstance },