Evan You 10 лет назад
Родитель
Сommit
f14201ecb8

+ 43 - 0
src/deprecations.js

@@ -0,0 +1,43 @@
+if (process.env.NODE_ENV !== 'production') {
+
+  var _ = require('./util')
+  var warn = function (msg) {
+    _.warn('{DEPRECATION} ' + msg)
+  }
+
+  _.deprecation = {
+
+    REPEAT_ALIAS: function () {
+      warn('v-repeat alias (e.g. item in items) will be required in 1.0.0.')
+    },
+
+    ADD: function () {
+      warn('$add() will be deprecated in 1.0.0. Use $set() instead.')
+    },
+
+    WAIT_FOR: function () {
+      warn('"wait-for" will be deprecated in 1.0.0. Use `activate` hook instead.')
+    },
+
+    STRICT_MODE: function () {
+      warn('Strict mode will default to `true` in 1.0.0.')
+    },
+
+    CONTENT_SELECT: function () {
+      warn('<content select="..."> will be deprecated in in 1.0.0. in favor of <content slot="...">.')
+    }
+
+  }
+
+  // ensure warning get warned only once
+  var warned = {}
+  Object.keys(_.deprecation).forEach(function (key) {
+    var fn = _.deprecation[key]
+    _.deprecation[key] = function () {
+      if (!warned[key]) {
+        warned[key] = true
+        fn()
+      }
+    }
+  })
+}

+ 7 - 0
src/directives/component.js

@@ -29,6 +29,13 @@ module.exports = {
       this.keepAlive = this._checkParam('keep-alive') != null
       // wait for event before insertion
       this.waitForEvent = this._checkParam('wait-for')
+
+      if (process.env.NODE_ENV !== 'production') {
+        if (this.waitForEvent) {
+          _.deprecation.WAIT_FOR()
+        }
+      }
+
       // check ref
       this.refID = this._checkParam(config.prefix + 'ref')
       if (this.keepAlive) {

+ 6 - 0
src/directives/repeat.js

@@ -45,6 +45,12 @@ module.exports = {
     // uid as a cache identifier
     this.id = '__v_repeat_' + (++uid)
 
+    if (process.env.NODE_ENV !== 'production') {
+      if (!this.arg) {
+        _.deprecation.REPEAT_ALIAS()
+      }
+    }
+
     // setup anchor nodes
     this.start = _.createAnchor('v-repeat-start')
     this.end = _.createAnchor('v-repeat-end')

+ 5 - 0
src/element-directives/content.js

@@ -44,6 +44,11 @@ module.exports = {
         compileDefaultContent()
       }
     } else {
+
+      if (process.env.NODE_ENV !== 'production') {
+        _.deprecation.CONTENT_SELECT()
+      }
+
       // select content
       var nodes = raw.querySelectorAll(selector)
       if (nodes.length) {

+ 3 - 0
src/observer/object.js

@@ -14,6 +14,9 @@ _.define(
   objProto,
   '$add',
   function $add (key, val) {
+    if (process.env.NODE_ENV !== 'production') {
+      _.deprecation.ADD()
+    }
     if (this.hasOwnProperty(key)) return
     var ob = this.__ob__
     if (!ob || _.isReserved(key)) {

+ 6 - 17
src/util/debug.js

@@ -7,6 +7,12 @@ if (process.env.NODE_ENV !== 'production') {
   var config = require('../config')
   var hasConsole = typeof console !== 'undefined'
 
+  /**
+   * Load deprecation warning functions
+   */
+
+  exports.deprecations = require('../deprecations')
+
   /**
    * Log a message.
    *
@@ -40,23 +46,6 @@ if (process.env.NODE_ENV !== 'production') {
    */
 
   exports.assertAsset = function (val, type, id) {
-    /* istanbul ignore if */
-    if (type === 'directive') {
-      if (id === 'with') {
-        exports.warn(
-          'v-with has been deprecated in ^0.12.0. ' +
-          'Use props instead.'
-        )
-        return
-      }
-      if (id === 'events') {
-        exports.warn(
-          'v-events has been deprecated in ^0.12.0. ' +
-          'Pass down methods as callback props instead.'
-        )
-        return
-      }
-    }
     if (!val) {
       exports.warn('Failed to resolve ' + type + ': ' + id)
     }

+ 7 - 0
src/util/options.js

@@ -344,6 +344,13 @@ exports.resolveAsset = function resolve (options, type, id) {
   var pascalizedId = camelizedId.charAt(0).toUpperCase() + camelizedId.slice(1)
   var assets = options[type]
   var asset = assets[id] || assets[camelizedId] || assets[pascalizedId]
+
+  if (process.env.NODE_ENV !== 'production') {
+    if (!asset && !config.strict) {
+      _.deprecation.STRICT_MODE()
+    }
+  }
+
   while (
     !asset &&
     options._parent &&