MCPcopy
hub / github.com/vuejs/core / installCompatInstanceProperties

Function installCompatInstanceProperties

packages/runtime-core/src/compat/instance.ts:65–199  ·  view source on GitHub ↗
(
  map: PublicPropertiesMap,
)

Source from the content-addressed store, hash-verified

63}
64
65export function installCompatInstanceProperties(
66 map: PublicPropertiesMap,
67): void {
68 const set = (target: any, key: any, val: any) => {
69 target[key] = val
70 return target[key]
71 }
72
73 const del = (target: any, key: any) => {
74 delete target[key]
75 }
76
77 extend(map, {
78 $set: i => {
79 assertCompatEnabled(DeprecationTypes.INSTANCE_SET, i)
80 return set
81 },
82
83 $delete: i => {
84 assertCompatEnabled(DeprecationTypes.INSTANCE_DELETE, i)
85 return del
86 },
87
88 $mount: i => {
89 assertCompatEnabled(
90 DeprecationTypes.GLOBAL_MOUNT,
91 null /* this warning is global */,
92 )
93 // root mount override from ./global.ts in installCompatMount
94 return i.ctx._compat_mount || NOOP
95 },
96
97 $destroy: i => {
98 assertCompatEnabled(DeprecationTypes.INSTANCE_DESTROY, i)
99 // root destroy override from ./global.ts in installCompatMount
100 return i.ctx._compat_destroy || NOOP
101 },
102
103 // overrides existing accessor
104 $slots: i => {
105 if (
106 isCompatEnabled(DeprecationTypes.RENDER_FUNCTION, i) &&
107 i.render &&
108 i.render._compatWrapped
109 ) {
110 return new Proxy(i.slots, legacySlotProxyHandlers)
111 }
112 return __DEV__ ? shallowReadonly(i.slots) : i.slots
113 },
114
115 $scopedSlots: i => {
116 assertCompatEnabled(DeprecationTypes.INSTANCE_SCOPED_SLOTS, i)
117 return __DEV__ ? shallowReadonly(i.slots) : i.slots
118 },
119
120 $on: i => on.bind(null, i),
121 $once: i => once.bind(null, i),
122 $off: i => off.bind(null, i),

Callers 1

Calls 4

assertCompatEnabledFunction · 0.90
isCompatEnabledFunction · 0.90
shallowReadonlyFunction · 0.90
resolveMergedOptionsFunction · 0.90

Tested by

no test coverage detected