Explorar o código

rename: init -> beforeCreate

Evan You %!s(int64=10) %!d(string=hai) anos
pai
achega
8c86973198

+ 1 - 1
src/core/config.js

@@ -84,7 +84,7 @@ const config: Config = {
    * List of lifecycle hooks.
    * List of lifecycle hooks.
    */
    */
   _lifecycleHooks: [
   _lifecycleHooks: [
-    'init',
+    'beforeCreate',
     'created',
     'created',
     'beforeMount',
     'beforeMount',
     'mounted',
     'mounted',

+ 1 - 1
src/core/instance/init.js

@@ -39,7 +39,7 @@ export function initMixin (Vue: Class<Component>) {
     vm._self = vm
     vm._self = vm
     initLifecycle(vm)
     initLifecycle(vm)
     initEvents(vm)
     initEvents(vm)
-    callHook(vm, 'init')
+    callHook(vm, 'beforeCreate')
     initState(vm)
     initState(vm)
     callHook(vm, 'created')
     callHook(vm, 'created')
     initRender(vm)
     initRender(vm)

+ 2 - 2
test/unit/features/global-api/mixin.spec.js

@@ -22,12 +22,12 @@ describe('Global API: mixin', () => {
     const calls = []
     const calls = []
     const Test = Vue.extend({
     const Test = Vue.extend({
       name: 'test',
       name: 'test',
-      init () {
+      beforeCreate () {
         calls.push(this.$options.myOption + ' local')
         calls.push(this.$options.myOption + ' local')
       }
       }
     })
     })
     Vue.mixin({
     Vue.mixin({
-      init () {
+      beforeCreate () {
         calls.push(this.$options.myOption + ' global')
         calls.push(this.$options.myOption + ' global')
       }
       }
     })
     })

+ 2 - 2
test/unit/features/options/lifecycle.spec.js

@@ -6,13 +6,13 @@ describe('Options lifecyce hooks', () => {
     spy = jasmine.createSpy('hook')
     spy = jasmine.createSpy('hook')
   })
   })
 
 
-  describe('init', () => {
+  describe('beforeCreate', () => {
     it('should allow modifying options', () => {
     it('should allow modifying options', () => {
       const vm = new Vue({
       const vm = new Vue({
         data: {
         data: {
           a: 1
           a: 1
         },
         },
-        init () {
+        beforeCreate () {
           spy()
           spy()
           expect(this.a).toBeUndefined()
           expect(this.a).toBeUndefined()
           this.$options.computed = {
           this.$options.computed = {