|
|
@@ -9,35 +9,38 @@ import { mergeOptions } from '../util/index'
|
|
|
|
|
|
let uid = 0
|
|
|
|
|
|
-export function init (vm: Component, options?: Object) {
|
|
|
- // a uid
|
|
|
- vm._uid = uid++
|
|
|
- // a flag to avoid this being observed
|
|
|
- vm._isVue = true
|
|
|
- // merge options
|
|
|
- if (options && options._isComponent) {
|
|
|
- // optimize internal component instantiation
|
|
|
- // since dynamic options merging is pretty slow, and none of the
|
|
|
- // internal component options needs special treatment.
|
|
|
- initInternalComponent(vm, options)
|
|
|
- } else {
|
|
|
- vm.$options = mergeOptions(
|
|
|
- vm.constructor.options,
|
|
|
- options || {},
|
|
|
- vm
|
|
|
- )
|
|
|
+export function initMixin (Vue: Class<Component>) {
|
|
|
+ Vue.prototype._init = function (options?: Object) {
|
|
|
+ const vm = this
|
|
|
+ // a uid
|
|
|
+ vm._uid = uid++
|
|
|
+ // a flag to avoid this being observed
|
|
|
+ vm._isVue = true
|
|
|
+ // merge options
|
|
|
+ if (options && options._isComponent) {
|
|
|
+ // optimize internal component instantiation
|
|
|
+ // since dynamic options merging is pretty slow, and none of the
|
|
|
+ // internal component options needs special treatment.
|
|
|
+ initInternalComponent(vm, options)
|
|
|
+ } else {
|
|
|
+ vm.$options = mergeOptions(
|
|
|
+ vm.constructor.options,
|
|
|
+ options || {},
|
|
|
+ vm
|
|
|
+ )
|
|
|
+ }
|
|
|
+ if (process.env.NODE_ENV !== 'production') {
|
|
|
+ initProxy(vm)
|
|
|
+ } else {
|
|
|
+ vm._renderProxy = vm
|
|
|
+ }
|
|
|
+ initLifecycle(vm)
|
|
|
+ initEvents(vm)
|
|
|
+ callHook(vm, 'init')
|
|
|
+ initState(vm)
|
|
|
+ callHook(vm, 'created')
|
|
|
+ initRender(vm)
|
|
|
}
|
|
|
- if (process.env.NODE_ENV !== 'production') {
|
|
|
- initProxy(vm)
|
|
|
- } else {
|
|
|
- vm._renderProxy = vm
|
|
|
- }
|
|
|
- initLifecycle(vm)
|
|
|
- initEvents(vm)
|
|
|
- callHook(vm, 'init')
|
|
|
- initState(vm)
|
|
|
- callHook(vm, 'created')
|
|
|
- initRender(vm)
|
|
|
}
|
|
|
|
|
|
function initInternalComponent (vm: Component, options: InternalComponentOptions) {
|