From ad844cf1e767137a713f715779969ffb94207c7a Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 7 Jun 2021 11:04:41 -0400 Subject: [PATCH] fix(compat): revert private properties on $options in comapt mode fix #3883 --- packages/runtime-core/src/compat/instance.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/runtime-core/src/compat/instance.ts b/packages/runtime-core/src/compat/instance.ts index 39f27f59..cc903956 100644 --- a/packages/runtime-core/src/compat/instance.ts +++ b/packages/runtime-core/src/compat/instance.ts @@ -37,6 +37,7 @@ import { import { resolveFilter } from '../helpers/resolveAssets' import { InternalSlots, Slots } from '../componentSlots' import { ContextualRenderFn } from '../componentRenderContext' +import { resolveMergedOptions } from '../componentOptions' export type LegacyPublicInstance = ComponentPublicInstance & LegacyPublicProperties @@ -127,6 +128,15 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) { // needed by many libs / render fns $vnode: i => i.vnode, + // inject addtional properties into $options for compat + // e.g. vuex needs this.$options.parent + $options: i => { + const res = extend({}, resolveMergedOptions(i)) + res.parent = i.proxy!.$parent + res.propsData = i.vnode.props + return res + }, + // some private properties that are likely accessed... _self: i => i.proxy, _uid: i => i.uid,