deprecations.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. if (process.env.NODE_ENV !== 'production') {
  2. var _ = require('./util')
  3. var warn = function (msg) {
  4. _.warn('{DEPRECATION} ' + msg)
  5. }
  6. var newBindingSyntaxLink = ' See https://github.com/yyx990803/vue/issues/1173 for details.'
  7. _.deprecation = {
  8. REPEAT: function () {
  9. warn(
  10. 'v-repeat will be deprecated in favor of v-for in 1.0.0. ' +
  11. 'See https://github.com/yyx990803/vue/issues/1200 for details.'
  12. )
  13. },
  14. ADD: function () {
  15. warn(
  16. '$add() will be deprecated in 1.0.0. Use $set() instead. ' +
  17. 'See https://github.com/yyx990803/vue/issues/1171 for details.'
  18. )
  19. },
  20. WAIT_FOR: function () {
  21. warn(
  22. '"wait-for" will be deprecated in 1.0.0. Use `activate` hook instead. ' +
  23. 'See https://github.com/yyx990803/vue/issues/1169 for details.'
  24. )
  25. },
  26. STRICT_MODE: function (type, id) {
  27. warn(
  28. 'Falling through to parent when resolving ' + type + ' with id "' + id +
  29. '". Strict mode will default to `true` in 1.0.0. ' +
  30. 'See https://github.com/yyx990803/vue/issues/1170 for details.'
  31. )
  32. },
  33. CONTENT: function () {
  34. warn(
  35. '<content> insertion points will be deprecated in in 1.0.0. in favor of <slot>. ' +
  36. 'See https://github.com/yyx990803/vue/issues/1167 for details.'
  37. )
  38. },
  39. DATA_AS_PROP: function () {
  40. warn(
  41. '$data will no longer be usable as a prop in 1.0.0. ' +
  42. 'See https://github.com/yyx990803/vue/issues/1198 for details.'
  43. )
  44. },
  45. INHERIT: function () {
  46. warn(
  47. 'The "inherit" option will be deprecated in 1.0.0. ' +
  48. 'See https://github.com/yyx990803/vue/issues/1198 for details.'
  49. )
  50. },
  51. V_EL: function () {
  52. warn(
  53. 'v-el will no longer be a directive in 1.0.0. Use the "el" special attribute instead. ' +
  54. 'See https://github.com/yyx990803/vue/issues/1198 for details.'
  55. )
  56. },
  57. DIR_ARGS: function (exp) {
  58. warn(
  59. 'Directives will no longer take arguments in 1.0.0. Found in directive ' +
  60. '"' + exp + '"' + newBindingSyntaxLink
  61. )
  62. },
  63. MUTI_CLAUSES: function () {
  64. warn(
  65. 'Directives will no longer support multiple clause syntax in 1.0.0.' +
  66. newBindingSyntaxLink
  67. )
  68. },
  69. V_TRANSITION: function () {
  70. warn(
  71. 'v-transition will no longer be a directive in 1.0.0; It will become a ' +
  72. 'special attribute without the prefix. Use "transition" instead. Also, ' +
  73. 'it will no longer attach the .v-transition class, but instead leave ' +
  74. 'the transition attribute on the element. If you were using the ' +
  75. '".name-transition" CSS selector before, you should now use the ' +
  76. '"[transition="name"]" selector instead.' +
  77. newBindingSyntaxLink
  78. )
  79. },
  80. V_REF: function () {
  81. warn(
  82. 'v-ref will no longer be a directive in 1.0.0; It will become a ' +
  83. 'special attribute without the prefix. Use "ref" instead.' +
  84. newBindingSyntaxLink
  85. )
  86. },
  87. V_CLASS: function () {
  88. warn(
  89. 'v-class will no longer be a directive in 1.0.0; Use "bind-class" instead.' +
  90. newBindingSyntaxLink
  91. )
  92. },
  93. V_STYLE: function () {
  94. warn(
  95. 'v-style will no longer be a directive in 1.0.0; Use "bind-style" instead.' +
  96. newBindingSyntaxLink
  97. )
  98. },
  99. V_ATTR: function () {
  100. warn(
  101. 'v-attr will no longer be a directive in 1.0.0; Use the "bind-" syntax instead.' +
  102. newBindingSyntaxLink
  103. )
  104. },
  105. V_ON: function () {
  106. warn(
  107. 'v-on will no longer be a directive in 1.0.0; Use the "on-" syntax instead.' +
  108. newBindingSyntaxLink
  109. )
  110. },
  111. ATTR_INTERPOLATION: function (name, value) {
  112. warn(
  113. 'Mustache interpolations inside attributes: ' + name + '="' + value + '". ' +
  114. 'This will be deprecated in 1.0.0. ' +
  115. 'Use the "bind-" syntax instead.' + newBindingSyntaxLink
  116. )
  117. },
  118. PROPS: function (attr, value) {
  119. warn(
  120. 'Prop ' + attr + '="' + value + '" should be prefixed with "prop-" and ' +
  121. 'bound as expression in 1.0.0. ' +
  122. 'For more details, see https://github.com/yyx990803/vue/issues/1173'
  123. )
  124. },
  125. COMPUTED_CACHE: function (name) {
  126. warn(
  127. 'Computed property "' + name + '": computed properties are not cached by ' +
  128. 'default in 1.0.0. You only need to enable cache for particularly expensive ones.'
  129. )
  130. },
  131. BIND_IS: function () {
  132. warn(
  133. '<component is="{{view}}"> syntax will be deprecated in 1.0.0. Use ' +
  134. '<component bind-is="view"> instead.'
  135. )
  136. },
  137. PARTIAL_NAME: function (id) {
  138. warn(
  139. '<partial name="' + id + '">: mustache interpolations inside attributes ' +
  140. 'will be deprecated in 1.0.0. Use bind-name="expression" instead.'
  141. )
  142. },
  143. REF_IN_CHILD: function () {
  144. warn(
  145. 'v-ref or ref can no longer be used on a component root in its own ' +
  146. 'template in 1.0.0. Use it in the parent template instead.'
  147. )
  148. },
  149. KEY_FILTER: function () {
  150. warn(
  151. 'The "key" filter will be deprecated in 1.0.0. Use the new ' +
  152. 'on-keyup:key="handler" syntax instead.'
  153. )
  154. },
  155. PROPAGATION: function (event) {
  156. warn(
  157. 'No need to return false in handler for event "' + event + '": events ' +
  158. 'no longer propagate beyond the first triggered handler unless the ' +
  159. 'handler explicitly returns true. See https://github.com/yyx990803/vue/issues/1175 ' +
  160. 'for more details.'
  161. )
  162. },
  163. MODEL_EXP: function (exp) {
  164. warn(
  165. 'Params "exp", "true-exp" and "false-exp" for v-model will be deprecated in 1.0.0. ' +
  166. 'Use "bind-value", "bind-true-value" and "bind-false-value" instead.'
  167. )
  168. },
  169. SELECT_OPTIONS: function () {
  170. warn(
  171. 'The "options" param for <select v-model> will be deprecated in 1.0.0. ' +
  172. 'Use v-for to render the options. See https://github.com/yyx990803/vue/issues/1229 ' +
  173. 'for more details.'
  174. )
  175. }
  176. }
  177. // ensure warning get warned only once
  178. var warned = {}
  179. Object.keys(_.deprecation).forEach(function (key) {
  180. var fn = _.deprecation[key]
  181. _.deprecation[key] = function () {
  182. if (!warned[key]) {
  183. warned[key] = true
  184. fn.apply(null, arguments)
  185. }
  186. }
  187. })
  188. }