-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
/
Copy pathcomponent.ts
212 lines (197 loc) · 5.65 KB
/
component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import type VNode from 'core/vdom/vnode'
import type Watcher from 'core/observer/watcher'
import { ComponentOptions } from './options'
import { SetupContext } from 'v3/apiSetup'
import { ScopedSlotsData, VNodeChildren, VNodeData } from './vnode'
import { GlobalAPI } from './global-api'
import { EffectScope } from 'v3/reactivity/effectScope'
// TODO this should be using the same as /component/
/**
* @internal
*/
export declare class Component {
constructor(options?: any)
// constructor information
static cid: number
static options: Record<string, any>
// extend
static extend: GlobalAPI['extend']
static superOptions: Record<string, any>
static extendOptions: Record<string, any>
static sealedOptions: Record<string, any>
static super: typeof Component
// assets
static directive: GlobalAPI['directive']
static component: GlobalAPI['component']
static filter: GlobalAPI['filter']
// functional context constructor
static FunctionalRenderContext: Function
static mixin: GlobalAPI['mixin']
static use: GlobalAPI['use']
// public properties
$el: any // so that we can attach __vue__ to it
$data: Record<string, any>
$props: Record<string, any>
$options: ComponentOptions
$parent: Component | undefined
$root: Component
$children: Array<Component>
$refs: {
[key: string]: Component | Element | Array<Component | Element> | undefined
}
$slots: { [key: string]: Array<VNode> }
$scopedSlots: { [key: string]: () => VNode[] | undefined }
$vnode: VNode // the placeholder node for the component in parent's render tree
$attrs: { [key: string]: string }
$listeners: Record<string, Function | Array<Function>>
$isServer: boolean
// public methods
$mount: (
el?: Element | string,
hydrating?: boolean
) => Component & { [key: string]: any }
$forceUpdate: () => void
$destroy: () => void
$set: <T>(
target: Record<string, any> | Array<T>,
key: string | number,
val: T
) => T
$delete: <T>(
target: Record<string, any> | Array<T>,
key: string | number
) => void
$watch: (
expOrFn: string | (() => any),
cb: Function,
options?: Record<string, any>
) => Function
$on: (event: string | Array<string>, fn: Function) => Component
$once: (event: string, fn: Function) => Component
$off: (event?: string | Array<string>, fn?: Function) => Component
$emit: (event: string, ...args: Array<any>) => Component
$nextTick: (fn: (...args: any[]) => any) => void | Promise<any>
$createElement: (
tag?: string | Component,
data?: Record<string, any>,
children?: VNodeChildren
) => VNode
// private properties
_uid: number | string
_name: string // this only exists in dev mode
_isVue: true
__v_skip: true
_self: Component
_renderProxy: Component
_renderContext?: Component
_watcher: Watcher | null
_scope: EffectScope
_computedWatchers: { [key: string]: Watcher }
_data: Record<string, any>
_props: Record<string, any>
_events: Record<string, any>
_inactive: boolean | null
_directInactive: boolean
_isMounted: boolean
_isDestroyed: boolean
_isBeingDestroyed: boolean
_vnode?: VNode | null // self root node
_staticTrees?: Array<VNode> | null // v-once cached trees
_hasHookEvent: boolean
_provided: Record<string, any>
// _virtualComponents?: { [key: string]: Component };
// @v3
_setupState?: Record<string, any>
_setupProxy?: Record<string, any>
_setupContext?: SetupContext
_attrsProxy?: Record<string, any>
_listenersProxy?: Record<string, Function | Function[]>
_slotsProxy?: Record<string, () => VNode[]>
_preWatchers?: Watcher[]
// private methods
// lifecycle
_init: Function
_mount: (el?: Element | void, hydrating?: boolean) => Component
_update: (vnode: VNode, hydrating?: boolean) => void
// rendering
_render: () => VNode
__patch__: (
a: Element | VNode | void | null,
b: VNode | null,
hydrating?: boolean,
removeOnly?: boolean,
parentElm?: any,
refElm?: any
) => any
// createElement
// _c is internal that accepts `normalizationType` optimization hint
_c: (
vnode?: VNode,
data?: VNodeData,
children?: VNodeChildren,
normalizationType?: number
) => VNode | void
// renderStatic
_m: (index: number, isInFor?: boolean) => VNode | VNodeChildren
// markOnce
_o: (
vnode: VNode | Array<VNode>,
index: number,
key: string
) => VNode | VNodeChildren
// toString
_s: (value: any) => string
// text to VNode
_v: (value: string | number) => VNode
// toNumber
_n: (value: string) => number | string
// empty vnode
_e: () => VNode
// loose equal
_q: (a: any, b: any) => boolean
// loose indexOf
_i: (arr: Array<any>, val: any) => number
// resolveFilter
_f: (id: string) => Function
// renderList
_l: (val: any, render: Function) => Array<VNode> | null
// renderSlot
_t: (
name: string,
fallback?: Array<VNode>,
props?: Record<string, any>
) => Array<VNode> | null
// apply v-bind object
_b: (
data: any,
tag: string,
value: any,
asProp: boolean,
isSync?: boolean
) => VNodeData
// apply v-on object
_g: (data: any, value: any) => VNodeData
// check custom keyCode
_k: (
eventKeyCode: number,
key: string,
builtInAlias?: number | Array<number>,
eventKeyName?: string
) => boolean | null
// resolve scoped slots
_u: (
scopedSlots: ScopedSlotsData,
res?: Record<string, any>
) => { [key: string]: Function }
// SSR specific
_ssrNode: Function
_ssrList: Function
_ssrEscape: Function
_ssrAttr: Function
_ssrAttrs: Function
_ssrDOMProps: Function
_ssrClass: Function
_ssrStyle: Function
// allow dynamic method registration
// [key: string]: any
}