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

Function add

packages/reactivity/src/collectionHandlers.ts:169–188  ·  view source on GitHub ↗
(this: SetTypes, value: unknown)

Source from the content-addressed store, hash-verified

167 }
168 : {
169 add(this: SetTypes, value: unknown) {
170 const target = toRaw(this)
171 const proto = getProto(target)
172 const rawValue = toRaw(value)
173 const valueToAdd =
174 !shallow && !isShallow(value) && !isReadonly(value)
175 ? rawValue
176 : value
177 const hadKey =
178 proto.has.call(target, valueToAdd) ||
179 (hasChanged(value, valueToAdd) &&
180 proto.has.call(target, value)) ||
181 (hasChanged(rawValue, valueToAdd) &&
182 proto.has.call(target, rawValue))
183 if (!hadKey) {
184 target.add(valueToAdd)
185 trigger(target, TriggerOpTypes.ADD, valueToAdd, valueToAdd)
186 }
187 return this
188 },
189 set(this: MapTypes, key: unknown, value: unknown) {
190 if (!shallow && !isShallow(value) && !isReadonly(value)) {
191 value = toRaw(value)

Callers

nothing calls this directly

Calls 6

toRawFunction · 0.90
isShallowFunction · 0.90
isReadonlyFunction · 0.90
hasChangedFunction · 0.90
triggerFunction · 0.90
getProtoFunction · 0.85

Tested by

no test coverage detected