Răsfoiți Sursa

improve strict mode deprecation warning, fix v-transition resolve context

Evan You 10 ani în urmă
părinte
comite
f503aa24bd
3 a modificat fișierele cu 9 adăugiri și 7 ștergeri
  1. 4 3
      src/deprecations.js
  2. 4 3
      src/directives/transition.js
  3. 1 1
      src/util/options.js

+ 4 - 3
src/deprecations.js

@@ -28,9 +28,10 @@ if (process.env.NODE_ENV !== 'production') {
       )
     },
 
-    STRICT_MODE: function () {
+    STRICT_MODE: function (type, id) {
       warn(
-        'Strict mode will default to `true` in 1.0.0. ' +
+        'Falling through to parent when resolving ' + type + ' with id "' + id +
+        '". Strict mode will default to `true` in 1.0.0. ' +
         'See https://github.com/yyx990803/vue/issues/1170 for details.'
       )
     },
@@ -72,7 +73,7 @@ if (process.env.NODE_ENV !== 'production') {
     _.deprecation[key] = function () {
       if (!warned[key]) {
         warned[key] = true
-        fn()
+        fn.apply(null, arguments)
       }
     }
   })

+ 4 - 3
src/directives/transition.js

@@ -14,10 +14,11 @@ module.exports = {
 
   update: function (id, oldId) {
     var el = this.el
-    var vm = this.el.__vue__ || this.vm
-    var hooks = _.resolveAsset(vm.$options, 'transitions', id)
+    // resolve on owner vm
+    var hooks = _.resolveAsset(this.vm.$options, 'transitions', id)
     id = id || 'v'
-    el.__v_trans = new Transition(el, id, hooks, vm)
+    // apply on closest vm
+    el.__v_trans = new Transition(el, id, hooks, this.el.__vue__ || this.vm)
     if (oldId) {
       _.removeClass(el, oldId + '-transition')
     }

+ 1 - 1
src/util/options.js

@@ -367,7 +367,7 @@ exports.resolveAsset = function resolve (options, type, id) {
 
   if (process.env.NODE_ENV !== 'production') {
     if (asset && !localAsset && !config.strict) {
-      _.deprecation.STRICT_MODE()
+      _.deprecation.STRICT_MODE(type, id)
     }
   }