Repository: vuejs/vue
Pull request: revert _init method for Vuex


Changed files:
filename: flow/component.js
patch: @@ -58,6 +58,7 @@ declare interface Component {
 
   // private methods
   // lifecycle
+  _init: Function;
   _mount: () => Component;
   _update: (vnode: VNode) => void;
   _updateFromParent: (

filename: src/core/global-api/extend.js
patch: @@ -1,7 +1,6 @@
 /* @flow */
 
 import config from '../config'
-import { init } from '../instance/init'
 import { warn, mergeOptions } from '../util/index'
 
 export function initExtend (Vue: GlobalAPI) {
@@ -34,7 +33,7 @@ export function initExtend (Vue: GlobalAPI) {
       }
     }
     const Sub = function VueComponent (options) {
-      init(this, options)
+      this._init(options)
     }
     Sub.prototype = Object.create(Super.prototype)
     Sub.prototype.constructor = Sub

filename: src/core/instance/index.js
patch: @@ -1,13 +1,14 @@
-import { init } from './init'
+import { initMixin } from './init'
 import { stateMixin } from './state'
 import { renderMixin } from './render'
 import { eventsMixin } from './events'
 import { lifecycleMixin } from './lifecycle'
 
 function Vue (options) {
-  init(this, options)
+  this._init(options)
 }
 
+initMixin(Vue)
 stateMixin(Vue)
 eventsMixin(Vue)
 lifecycleMixin(Vue)

filename: src/core/instance/init.js
patch: @@ -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) {