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

Function createPropsDefaultThis

packages/runtime-core/src/compat/props.ts:10–43  ·  view source on GitHub ↗
(
  instance: ComponentInternalInstance,
  rawProps: Data,
  propKey: string,
)

Source from the content-addressed store, hash-verified

8import { DeprecationTypes, warnDeprecation } from './compatConfig'
9
10export function createPropsDefaultThis(
11 instance: ComponentInternalInstance,
12 rawProps: Data,
13 propKey: string,
14): object {
15 return new Proxy(
16 {},
17 {
18 get(_, key: string) {
19 __DEV__ &&
20 warnDeprecation(DeprecationTypes.PROPS_DEFAULT_THIS, null, propKey)
21 // $options
22 if (key === '$options') {
23 return resolveMergedOptions(instance)
24 }
25 // props
26 if (key in rawProps) {
27 return rawProps[key]
28 }
29 // injections
30 const injections = (instance.type as ComponentOptions).inject
31 if (injections) {
32 if (isArray(injections)) {
33 if (injections.includes(key)) {
34 return inject(key)
35 }
36 } else if (key in injections) {
37 return inject(key)
38 }
39 }
40 },
41 },
42 )
43}

Callers 1

resolvePropValueFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected