-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
89 lines (72 loc) · 2.28 KB
/
init.js
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
var mergeOptions = require('../util').mergeOptions
/**
* The main init sequence. This is called for every
* instance, including ones that are created from extended
* constructors.
*
* @param {Object} options - this options object should be
* the result of merging class
* options and the options passed
* in to the constructor.
*/
exports._init = function (options) {
options = options || {}
this.$el = null
this.$parent = options._parent
this.$root = options._root || this
this.$children = []
this.$ = {} // child vm references
this.$$ = {} // element references
this._watchers = [] // all watchers as an array
this._directives = [] // all directives
this._childCtors = {} // inherit:true constructors
// a flag to avoid this being observed
this._isVue = true
// events bookkeeping
this._events = {} // registered callbacks
this._eventsCount = {} // for $broadcast optimization
this._eventCancelled = false // for event cancellation
// block instance properties
this._isBlock = false
this._blockStart = // @type {CommentNode}
this._blockEnd = null // @type {CommentNode}
// lifecycle state
this._isCompiled =
this._isDestroyed =
this._isReady =
this._isAttached =
this._isBeingDestroyed = false
this._unlinkFn = null
// context: the scope in which the component was used,
// and the scope in which props and contents of this
// instance should be compiled in.
this._context =
options._context ||
options._parent
// push self into parent / transclusion host
if (this.$parent) {
this.$parent.$children.push(this)
}
// props used in v-repeat diffing
this._reused = false
this._staggerOp = null
// merge options.
options = this.$options = mergeOptions(
this.constructor.options,
options,
this
)
// initialize data as empty object.
// it will be filled up in _initScope().
this._data = {}
// initialize data observation and scope inheritance.
this._initScope()
// setup event system and option events.
this._initEvents()
// call created hook
this._callHook('created')
// if `el` option is passed, start compilation.
if (options.el) {
this.$mount(options.el)
}
}