refactor: adjust component options merge cache strategy

BREAKING CHANGE: optionMergeStrategies functions no longer receive
the component instance as the 3rd argument. The argument was technically
internal in Vue 2 and only used for generating warnings, and should not
be needed in userland code. This removal enables much more efficient
caching of option merging.
This commit is contained in:
Evan You
2021-06-02 10:37:50 -04:00
parent 44996d1a0a
commit 1e35a860b9
4 changed files with 86 additions and 43 deletions

View File

@@ -35,7 +35,6 @@ import {
legacyresolveScopedSlots
} from './renderHelpers'
import { resolveFilter } from '../helpers/resolveAssets'
import { resolveMergedOptions } from '../componentOptions'
import { InternalSlots, Slots } from '../componentSlots'
import { ContextualRenderFn } from '../componentRenderContext'
@@ -128,16 +127,6 @@ 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 => {
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
},
// some private properties that are likely accessed...
_self: i => i.proxy,
_uid: i => i.uid,