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

Method constructor

packages/reactivity/src/ref.ts:383–403  ·  packages/reactivity/src/ref.ts::ObjectRefImpl.constructor
(
    private readonly _object: T,
    key: K,
    private readonly _defaultValue?: T[K],
  )

Source from the content-addressed store, hash-verified

381 private readonly _shallow: boolean
382
383 constructor(
384 private readonly _object: T,
385 key: K,
386 private readonly _defaultValue?: T[K],
387 ) {
388 this._key = (isSymbol(key) ? key : String(key)) as K
389 this._raw = toRaw(_object)
390
391 let shallow = true
392 let obj = _object
393
394 class="cm">// For an array with integer key, refs are not unwrapped
395 if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) {
396 class="cm">// Otherwise, check each proxy layer for unwrapping
397 do {
398 shallow = !isProxy(obj) || isShallow(obj)
399 } while (shallow && (obj = (obj as Target)[ReactiveFlags.RAW]))
400 }
401
402 this._shallow = shallow
403 }
404
405 get value() {
406 let val = this._object[this._key]

Callers

nothing calls this directly

Calls 6

isSymbolFunction · 0.90
toRawFunction · 0.90
isIntegerKeyFunction · 0.90
isProxyFunction · 0.90
isShallowFunction · 0.90
StringInterface · 0.85

Tested by

no test coverage detected