Browse Source

use pre-hook for setting up prop two-way sync (fix #2064)

Evan You 10 years ago
parent
commit
03b580e05c

+ 1 - 1
src/directives/internal/prop.js

@@ -46,7 +46,7 @@ export default {
       // important: defer the child watcher creation until
       // the created hook (after data observation)
       var self = this
-      child.$once('hook:created', function () {
+      child.$once('pre-hook:created', function () {
         self.childWatcher = new Watcher(
           child,
           childKey,

+ 1 - 1
src/directives/public/cloak.js

@@ -1,7 +1,7 @@
 export default {
   bind () {
     var el = this.el
-    this.vm.$once('hook:compiled', function () {
+    this.vm.$once('pre-hook:compiled', function () {
       el.removeAttribute('v-cloak')
     })
   }

+ 1 - 0
src/instance/internal/events.js

@@ -159,6 +159,7 @@ export default function (Vue) {
    */
 
   Vue.prototype._callHook = function (hook) {
+    this.$emit('pre-hook:' + hook)
     var handlers = this.$options[hook]
     if (handlers) {
       for (var i = 0, j = handlers.length; i < j; i++) {