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

Function get

packages/reactivity/src/collectionHandlers.ts:101–124  ·  view source on GitHub ↗
(this: MapTypes, key: unknown)

Source from the content-addressed store, hash-verified

99): Instrumentations {
100 const instrumentations: Instrumentations = {
101 get(this: MapTypes, key: unknown) {
102 // #1772: readonly(reactive(Map)) should return readonly + reactive version
103 // of the value
104 const target = this[ReactiveFlags.RAW]
105 const rawTarget = toRaw(target)
106 const rawKey = toRaw(key)
107 if (!readonly) {
108 if (hasChanged(key, rawKey)) {
109 track(rawTarget, TrackOpTypes.GET, key)
110 }
111 track(rawTarget, TrackOpTypes.GET, rawKey)
112 }
113 const { has } = getProto(rawTarget)
114 const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive
115 if (has.call(rawTarget, key)) {
116 return wrap(target.get(key))
117 } else if (has.call(rawTarget, rawKey)) {
118 return wrap(target.get(rawKey))
119 } else if (target !== rawTarget) {
120 // #3602 readonly(reactive(Map))
121 // ensure that the nested reactive `Map` can do tracking for itself
122 target.get(key)
123 }
124 },
125 get size() {
126 const target = (this as unknown as IterableCollections)[ReactiveFlags.RAW]
127 !readonly && track(toRaw(target), TrackOpTypes.ITERATE, ITERATE_KEY)

Callers

nothing calls this directly

Calls 5

toRawFunction · 0.90
hasChangedFunction · 0.90
trackFunction · 0.90
getProtoFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected