| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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
- // fragment instance properties
- this._isFragment = false
- this._fragmentStart = // @type {CommentNode}
- this._fragmentEnd = null // @type {CommentNode}
- // lifecycle state
- this._isCompiled =
- this._isDestroyed =
- this._isReady =
- this._isAttached =
- this._isBeingDestroyed = false
- this._unlinkFn = null
- // context:
- // if this is a transcluded component, context
- // will be the common parent vm of this instance
- // and its host.
- this._context = options._context || options._parent
- // scope:
- // if this is inside an inline v-repeat, the scope
- // will be the intermediate scope created for this
- // repeat fragment. this is used for linking props
- // and container directives.
- this._scope = options._scope
- // 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)
- }
- }
|