revert _init method for Vuex (#2886)

This commit is contained in:
Jinjiang 2016-05-17 21:58:24 +08:00 committed by Evan You
parent 36a32e4466
commit 2e8dfe5d9a
4 changed files with 36 additions and 32 deletions

View File

@ -58,6 +58,7 @@ declare interface Component {
// private methods
// lifecycle
_init: Function;
_mount: () => Component;
_update: (vnode: VNode) => void;
_updateFromParent: (

View File

@ -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

View File

@ -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)

View File

@ -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) {