vue 2.6.13 → 2.7.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/README.md +17 -295
  2. package/compiler-sfc/index.d.ts +1 -0
  3. package/compiler-sfc/index.js +1 -0
  4. package/compiler-sfc/index.mjs +1 -0
  5. package/compiler-sfc/package.json +5 -0
  6. package/dist/vue.common.dev.js +11481 -11946
  7. package/dist/vue.common.prod.js +8 -3
  8. package/dist/vue.esm.browser.js +11321 -12011
  9. package/dist/vue.esm.browser.min.js +8 -3
  10. package/dist/vue.esm.js +11476 -11984
  11. package/dist/vue.js +11484 -11949
  12. package/dist/vue.min.js +8 -3
  13. package/dist/vue.runtime.common.dev.js +8427 -8421
  14. package/dist/vue.runtime.common.prod.js +8 -3
  15. package/dist/vue.runtime.esm.js +8436 -8454
  16. package/dist/vue.runtime.js +8430 -8424
  17. package/dist/vue.runtime.min.js +8 -3
  18. package/package.json +88 -111
  19. package/packages/compiler-sfc/dist/compiler-sfc.js +7 -0
  20. package/packages/compiler-sfc/node_modules/.bin/parser +17 -0
  21. package/packages/compiler-sfc/node_modules/.bin/sass +17 -0
  22. package/packages/compiler-sfc/package.json +30 -0
  23. package/src/compiler/{codeframe.js → codeframe.ts} +9 -7
  24. package/src/compiler/codegen/{events.js → events.ts} +21 -41
  25. package/src/compiler/codegen/{index.js → index.ts} +146 -136
  26. package/src/compiler/{create-compiler.js → create-compiler.ts} +26 -18
  27. package/src/compiler/directives/bind.ts +9 -0
  28. package/src/compiler/directives/{index.js → index.ts} +0 -2
  29. package/src/compiler/directives/{model.js → model.ts} +15 -18
  30. package/src/compiler/directives/{on.js → on.ts} +3 -4
  31. package/src/compiler/{error-detector.js → error-detector.ts} +61 -31
  32. package/src/compiler/{helpers.js → helpers.ts} +73 -61
  33. package/src/compiler/{index.js → index.ts} +2 -3
  34. package/src/compiler/{optimizer.js → optimizer.ts} +30 -23
  35. package/src/compiler/parser/{entity-decoder.js → entity-decoder.ts} +1 -3
  36. package/src/compiler/parser/{filter-parser.js → filter-parser.ts} +43 -24
  37. package/src/compiler/parser/{html-parser.js → html-parser.ts} +50 -29
  38. package/src/compiler/parser/{index.js → index.ts} +190 -172
  39. package/src/compiler/parser/{text-parser.js → text-parser.ts} +8 -9
  40. package/src/compiler/{to-function.js → to-function.ts} +27 -22
  41. package/src/core/components/{index.js → index.ts} +0 -0
  42. package/src/core/components/{keep-alive.js → keep-alive.ts} +42 -30
  43. package/src/core/{config.js → config.ts} +28 -30
  44. package/src/core/global-api/{assets.js → assets.ts} +8 -7
  45. package/src/core/global-api/{extend.js → extend.ts} +10 -13
  46. package/src/core/global-api/{index.js → index.ts} +4 -5
  47. package/src/core/global-api/{mixin.js → mixin.ts} +2 -3
  48. package/src/core/global-api/use.ts +23 -0
  49. package/src/core/{index.js → index.ts} +1 -1
  50. package/src/core/instance/{events.js → events.ts} +41 -24
  51. package/src/core/instance/{index.js → index.ts} +9 -5
  52. package/src/core/instance/{init.js → init.ts} +26 -15
  53. package/src/core/instance/inject.ts +72 -0
  54. package/src/core/instance/{lifecycle.js → lifecycle.ts} +86 -44
  55. package/src/core/instance/{proxy.js → proxy.ts} +29 -24
  56. package/src/core/instance/render-helpers/{bind-dynamic-keys.js → bind-dynamic-keys.ts} +6 -5
  57. package/src/core/instance/render-helpers/{bind-object-listeners.js → bind-object-listeners.ts} +4 -8
  58. package/src/core/instance/render-helpers/{bind-object-props.js → bind-object-props.ts} +12 -17
  59. package/src/core/instance/render-helpers/{check-keycodes.js → check-keycodes.ts} +5 -7
  60. package/src/core/instance/render-helpers/{index.js → index.ts} +1 -3
  61. package/src/core/instance/render-helpers/{render-list.js → render-list.ts} +12 -13
  62. package/src/core/instance/render-helpers/{render-slot.js → render-slot.ts} +10 -11
  63. package/src/core/instance/render-helpers/{render-static.js → render-static.ts} +7 -10
  64. package/src/core/instance/render-helpers/{resolve-filter.js → resolve-filter.ts} +1 -3
  65. package/src/core/instance/render-helpers/{resolve-scoped-slots.js → resolve-scoped-slots.ts} +11 -8
  66. package/src/core/instance/render-helpers/{resolve-slots.js → resolve-slots.ts} +12 -11
  67. package/src/core/instance/{render.js → render.ts} +66 -29
  68. package/src/core/instance/{state.js → state.ts} +100 -83
  69. package/src/core/observer/{array.js → array.ts} +11 -2
  70. package/src/core/observer/{dep.js → dep.ts} +37 -15
  71. package/src/core/observer/{index.js → index.ts} +137 -71
  72. package/src/core/observer/{scheduler.js → scheduler.ts} +42 -43
  73. package/src/core/observer/{traverse.js → traverse.ts} +10 -7
  74. package/src/core/observer/{watcher.js → watcher.ts} +88 -60
  75. package/src/core/util/{debug.js → debug.ts} +38 -34
  76. package/src/core/util/{env.js → env.ts} +27 -30
  77. package/src/core/util/{error.js → error.ts} +12 -14
  78. package/src/core/util/{index.js → index.ts} +0 -2
  79. package/src/core/util/{lang.js → lang.ts} +6 -7
  80. package/src/core/util/{next-tick.js → next-tick.ts} +16 -10
  81. package/src/core/util/{options.js → options.ts} +119 -114
  82. package/src/core/util/{perf.js → perf.ts} +5 -1
  83. package/src/core/util/{props.js → props.ts} +54 -50
  84. package/src/core/vdom/{create-component.js → create-component.ts} +51 -50
  85. package/src/core/vdom/{create-element.js → create-element.ts} +49 -43
  86. package/src/core/vdom/{create-functional-component.js → create-functional-component.ts} +52 -27
  87. package/src/core/vdom/helpers/{extract-props.js → extract-props.ts} +18 -18
  88. package/src/core/vdom/helpers/{get-first-component-child.js → get-first-component-child.ts} +6 -5
  89. package/src/core/vdom/helpers/{index.js → index.ts} +0 -2
  90. package/src/core/vdom/helpers/is-async-placeholder.ts +6 -0
  91. package/src/core/vdom/helpers/{merge-hook.js → merge-hook.ts} +7 -5
  92. package/src/core/vdom/helpers/{normalize-children.js → normalize-children.ts} +26 -16
  93. package/src/core/vdom/helpers/{normalize-scoped-slots.js → normalize-scoped-slots.ts} +23 -17
  94. package/src/core/vdom/helpers/{resolve-async-component.js → resolve-async-component.ts} +29 -37
  95. package/src/core/vdom/helpers/update-listeners.ts +101 -0
  96. package/src/core/vdom/modules/{directives.js → directives.ts} +20 -14
  97. package/src/core/vdom/modules/index.ts +4 -0
  98. package/src/core/vdom/modules/template-ref.ts +96 -0
  99. package/src/core/vdom/{patch.js → patch.ts} +239 -138
  100. package/src/core/vdom/{vnode.js → vnode.ts} +36 -31
  101. package/src/global.d.ts +15 -0
  102. package/src/platforms/web/compiler/directives/html.ts +8 -0
  103. package/src/platforms/web/compiler/directives/{index.js → index.ts} +0 -0
  104. package/src/platforms/web/compiler/directives/{model.js → model.ts} +47 -41
  105. package/src/platforms/web/compiler/directives/{text.js → text.ts} +2 -3
  106. package/src/platforms/web/compiler/{index.js → index.ts} +0 -2
  107. package/src/platforms/web/compiler/modules/{class.js → class.ts} +10 -15
  108. package/src/platforms/web/compiler/modules/{index.js → index.ts} +1 -5
  109. package/src/platforms/web/compiler/modules/{model.js → model.ts} +6 -11
  110. package/src/platforms/web/compiler/modules/{style.js → style.ts} +9 -14
  111. package/src/platforms/web/compiler/{options.js → options.ts} +1 -2
  112. package/src/platforms/web/compiler/{util.js → util.ts} +5 -7
  113. package/src/platforms/web/entry-compiler-sfc.ts +1 -0
  114. package/src/platforms/web/{entry-compiler.js → entry-compiler.ts} +1 -3
  115. package/src/platforms/web/{entry-runtime.js → entry-runtime-esm.ts} +2 -2
  116. package/src/platforms/web/entry-runtime-with-compiler-esm.ts +5 -0
  117. package/src/platforms/web/entry-runtime-with-compiler.ts +10 -0
  118. package/src/platforms/web/entry-runtime.ts +7 -0
  119. package/src/platforms/web/runtime/{class-util.js → class-util.ts} +2 -4
  120. package/src/platforms/web/runtime/components/{index.js → index.ts} +0 -0
  121. package/src/platforms/web/runtime/components/{transition-group.js → transition-group.ts} +59 -46
  122. package/src/platforms/web/runtime/components/{transition.js → transition.ts} +43 -36
  123. package/src/platforms/web/runtime/directives/{index.js → index.ts} +0 -0
  124. package/src/platforms/web/runtime/directives/{model.js → model.ts} +22 -21
  125. package/src/platforms/web/runtime/directives/{show.js → show.ts} +11 -10
  126. package/src/platforms/web/runtime/{index.js → index.ts} +9 -10
  127. package/src/platforms/web/runtime/modules/{attrs.js → attrs.ts} +12 -16
  128. package/src/platforms/web/runtime/modules/{class.js → class.ts} +7 -18
  129. package/src/platforms/web/runtime/modules/{dom-props.js → dom-props.ts} +24 -17
  130. package/src/platforms/web/runtime/modules/{events.js → events.ts} +22 -15
  131. package/src/platforms/web/runtime/modules/{index.js → index.ts} +1 -8
  132. package/src/platforms/web/runtime/modules/{style.js → style.ts} +24 -13
  133. package/src/platforms/web/runtime/modules/{transition.js → transition.ts} +61 -63
  134. package/src/platforms/web/runtime/node-ops.ts +66 -0
  135. package/src/platforms/web/runtime/{patch.js → patch.ts} +0 -2
  136. package/src/platforms/web/runtime/{transition-util.js → transition-util.ts} +63 -38
  137. package/src/platforms/web/{entry-runtime-with-compiler.js → runtime-with-compiler.ts} +28 -19
  138. package/src/platforms/web/util/{attrs.js → attrs.ts} +18 -14
  139. package/src/platforms/web/util/{class.js → class.ts} +23 -21
  140. package/src/platforms/web/util/{compat.js → compat.ts} +4 -4
  141. package/src/platforms/web/util/{element.js → element.ts} +21 -22
  142. package/src/platforms/web/util/{index.js → index.ts} +2 -6
  143. package/src/platforms/web/util/{style.js → style.ts} +12 -12
  144. package/src/sfc/{parser.js → parser.ts} +18 -15
  145. package/src/shared/{constants.js → constants.ts} +2 -6
  146. package/src/shared/{util.js → util.ts} +78 -55
  147. package/src/types/compiler.ts +224 -0
  148. package/src/types/component.ts +209 -0
  149. package/src/types/global-api.ts +37 -0
  150. package/src/types/modules.d.ts +15 -0
  151. package/src/types/options.ts +120 -0
  152. package/src/types/ssr.ts +27 -0
  153. package/src/types/utils.ts +3 -0
  154. package/src/types/vnode.ts +127 -0
  155. package/src/v3/apiInject.ts +66 -0
  156. package/src/v3/apiLifecycle.ts +53 -0
  157. package/src/v3/apiSetup.ts +161 -0
  158. package/src/v3/apiWatch.ts +355 -0
  159. package/src/v3/currentInstance.ts +23 -0
  160. package/src/v3/debug.ts +21 -0
  161. package/src/v3/h.ts +18 -0
  162. package/src/v3/index.ts +77 -0
  163. package/src/v3/reactivity/computed.ts +100 -0
  164. package/src/v3/reactivity/effect.ts +20 -0
  165. package/src/v3/reactivity/effectScope.ts +134 -0
  166. package/src/v3/reactivity/operations.ts +14 -0
  167. package/src/v3/reactivity/reactive.ts +123 -0
  168. package/src/v3/reactivity/readonly.ts +121 -0
  169. package/src/v3/reactivity/ref.ts +249 -0
  170. package/types/index.d.ts +10 -13
  171. package/types/options.d.ts +265 -132
  172. package/types/plugin.d.ts +4 -4
  173. package/types/umd.d.ts +47 -27
  174. package/types/v3-generated.d.ts +389 -0
  175. package/types/v3.d.ts +16 -0
  176. package/types/vnode.d.ts +70 -57
  177. package/types/vue.d.ts +292 -88
  178. package/dist/README.md +0 -122
  179. package/src/compiler/directives/bind.js +0 -11
  180. package/src/core/global-api/use.js +0 -23
  181. package/src/core/instance/inject.js +0 -73
  182. package/src/core/vdom/helpers/is-async-placeholder.js +0 -5
  183. package/src/core/vdom/helpers/update-listeners.js +0 -95
  184. package/src/core/vdom/modules/index.js +0 -7
  185. package/src/core/vdom/modules/ref.js +0 -45
  186. package/src/platforms/web/compiler/directives/html.js +0 -9
  187. package/src/platforms/web/entry-server-basic-renderer.js +0 -13
  188. package/src/platforms/web/entry-server-renderer.js +0 -27
  189. package/src/platforms/web/runtime/node-ops.js +0 -59
  190. package/src/platforms/web/server/compiler.js +0 -11
  191. package/src/platforms/web/server/directives/index.js +0 -7
  192. package/src/platforms/web/server/directives/model.js +0 -44
  193. package/src/platforms/web/server/directives/show.js +0 -12
  194. package/src/platforms/web/server/modules/attrs.js +0 -67
  195. package/src/platforms/web/server/modules/class.js +0 -11
  196. package/src/platforms/web/server/modules/dom-props.js +0 -50
  197. package/src/platforms/web/server/modules/index.js +0 -11
  198. package/src/platforms/web/server/modules/style.js +0 -41
  199. package/src/platforms/web/server/util.js +0 -101
  200. package/src/platforms/weex/compiler/directives/index.js +0 -5
  201. package/src/platforms/weex/compiler/directives/model.js +0 -33
  202. package/src/platforms/weex/compiler/index.js +0 -52
  203. package/src/platforms/weex/compiler/modules/append.js +0 -27
  204. package/src/platforms/weex/compiler/modules/class.js +0 -74
  205. package/src/platforms/weex/compiler/modules/index.js +0 -13
  206. package/src/platforms/weex/compiler/modules/props.js +0 -37
  207. package/src/platforms/weex/compiler/modules/recycle-list/component-root.js +0 -13
  208. package/src/platforms/weex/compiler/modules/recycle-list/component.js +0 -16
  209. package/src/platforms/weex/compiler/modules/recycle-list/index.js +0 -60
  210. package/src/platforms/weex/compiler/modules/recycle-list/recycle-list.js +0 -50
  211. package/src/platforms/weex/compiler/modules/recycle-list/text.js +0 -23
  212. package/src/platforms/weex/compiler/modules/recycle-list/v-bind.js +0 -21
  213. package/src/platforms/weex/compiler/modules/recycle-list/v-for.js +0 -33
  214. package/src/platforms/weex/compiler/modules/recycle-list/v-if.js +0 -63
  215. package/src/platforms/weex/compiler/modules/recycle-list/v-on.js +0 -25
  216. package/src/platforms/weex/compiler/modules/recycle-list/v-once.js +0 -19
  217. package/src/platforms/weex/compiler/modules/style.js +0 -87
  218. package/src/platforms/weex/entry-compiler.js +0 -2
  219. package/src/platforms/weex/entry-framework.js +0 -187
  220. package/src/platforms/weex/entry-runtime-factory.js +0 -6
  221. package/src/platforms/weex/runtime/components/index.js +0 -9
  222. package/src/platforms/weex/runtime/components/richtext.js +0 -82
  223. package/src/platforms/weex/runtime/components/transition-group.js +0 -148
  224. package/src/platforms/weex/runtime/components/transition.js +0 -9
  225. package/src/platforms/weex/runtime/directives/index.js +0 -2
  226. package/src/platforms/weex/runtime/index.js +0 -42
  227. package/src/platforms/weex/runtime/modules/attrs.js +0 -44
  228. package/src/platforms/weex/runtime/modules/class.js +0 -76
  229. package/src/platforms/weex/runtime/modules/events.js +0 -54
  230. package/src/platforms/weex/runtime/modules/index.js +0 -13
  231. package/src/platforms/weex/runtime/modules/style.js +0 -84
  232. package/src/platforms/weex/runtime/modules/transition.js +0 -270
  233. package/src/platforms/weex/runtime/node-ops.js +0 -91
  234. package/src/platforms/weex/runtime/patch.js +0 -16
  235. package/src/platforms/weex/runtime/recycle-list/render-component-template.js +0 -34
  236. package/src/platforms/weex/runtime/recycle-list/virtual-component.js +0 -136
  237. package/src/platforms/weex/runtime/text-node.js +0 -9
  238. package/src/platforms/weex/util/element.js +0 -52
  239. package/src/platforms/weex/util/index.js +0 -40
  240. package/src/platforms/weex/util/parser.js +0 -60
  241. package/src/server/bundle-renderer/create-bundle-renderer.js +0 -151
  242. package/src/server/bundle-renderer/create-bundle-runner.js +0 -150
  243. package/src/server/bundle-renderer/source-map-support.js +0 -45
  244. package/src/server/create-basic-renderer.js +0 -37
  245. package/src/server/create-renderer.js +0 -152
  246. package/src/server/optimizing-compiler/codegen.js +0 -264
  247. package/src/server/optimizing-compiler/index.js +0 -20
  248. package/src/server/optimizing-compiler/modules.js +0 -124
  249. package/src/server/optimizing-compiler/optimizer.js +0 -141
  250. package/src/server/optimizing-compiler/runtime-helpers.js +0 -150
  251. package/src/server/render-context.js +0 -130
  252. package/src/server/render-stream.js +0 -95
  253. package/src/server/render.js +0 -437
  254. package/src/server/template-renderer/create-async-file-mapper.js +0 -57
  255. package/src/server/template-renderer/index.js +0 -277
  256. package/src/server/template-renderer/parse-template.js +0 -42
  257. package/src/server/template-renderer/template-stream.js +0 -82
  258. package/src/server/util.js +0 -18
  259. package/src/server/webpack-plugin/client.js +0 -65
  260. package/src/server/webpack-plugin/server.js +0 -66
  261. package/src/server/webpack-plugin/util.js +0 -34
  262. package/src/server/write.js +0 -50
@@ -5,21 +5,21 @@ import { warn, makeMap, isNative } from '../util/index'
5
5
 
6
6
  let initProxy
7
7
 
8
- if (process.env.NODE_ENV !== 'production') {
8
+ if (__DEV__) {
9
9
  const allowedGlobals = makeMap(
10
10
  'Infinity,undefined,NaN,isFinite,isNaN,' +
11
- 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
12
- 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
13
- 'require' // for Webpack/Browserify
11
+ 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
12
+ 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
13
+ 'require' // for Webpack/Browserify
14
14
  )
15
15
 
16
16
  const warnNonPresent = (target, key) => {
17
17
  warn(
18
18
  `Property or method "${key}" is not defined on the instance but ` +
19
- 'referenced during render. Make sure that this property is reactive, ' +
20
- 'either in the data option, or for class-based components, by ' +
21
- 'initializing the property. ' +
22
- 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
19
+ 'referenced during render. Make sure that this property is reactive, ' +
20
+ 'either in the data option, or for class-based components, by ' +
21
+ 'initializing the property. ' +
22
+ 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
23
23
  target
24
24
  )
25
25
  }
@@ -27,22 +27,25 @@ if (process.env.NODE_ENV !== 'production') {
27
27
  const warnReservedPrefix = (target, key) => {
28
28
  warn(
29
29
  `Property "${key}" must be accessed with "$data.${key}" because ` +
30
- 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
31
- 'prevent conflicts with Vue internals. ' +
32
- 'See: https://vuejs.org/v2/api/#data',
30
+ 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
31
+ 'prevent conflicts with Vue internals. ' +
32
+ 'See: https://vuejs.org/v2/api/#data',
33
33
  target
34
34
  )
35
35
  }
36
36
 
37
- const hasProxy =
38
- typeof Proxy !== 'undefined' && isNative(Proxy)
37
+ const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy)
39
38
 
40
39
  if (hasProxy) {
41
- const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact')
40
+ const isBuiltInModifier = makeMap(
41
+ 'stop,prevent,self,ctrl,shift,alt,meta,exact'
42
+ )
42
43
  config.keyCodes = new Proxy(config.keyCodes, {
43
- set (target, key, value) {
44
+ set(target, key: string, value) {
44
45
  if (isBuiltInModifier(key)) {
45
- warn(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`)
46
+ warn(
47
+ `Avoid overwriting built-in modifier in config.keyCodes: .${key}`
48
+ )
46
49
  return false
47
50
  } else {
48
51
  target[key] = value
@@ -53,10 +56,13 @@ if (process.env.NODE_ENV !== 'production') {
53
56
  }
54
57
 
55
58
  const hasHandler = {
56
- has (target, key) {
59
+ has(target, key) {
57
60
  const has = key in target
58
- const isAllowed = allowedGlobals(key) ||
59
- (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data))
61
+ const isAllowed =
62
+ allowedGlobals(key) ||
63
+ (typeof key === 'string' &&
64
+ key.charAt(0) === '_' &&
65
+ !(key in target.$data))
60
66
  if (!has && !isAllowed) {
61
67
  if (key in target.$data) warnReservedPrefix(target, key)
62
68
  else warnNonPresent(target, key)
@@ -66,7 +72,7 @@ if (process.env.NODE_ENV !== 'production') {
66
72
  }
67
73
 
68
74
  const getHandler = {
69
- get (target, key) {
75
+ get(target, key) {
70
76
  if (typeof key === 'string' && !(key in target)) {
71
77
  if (key in target.$data) warnReservedPrefix(target, key)
72
78
  else warnNonPresent(target, key)
@@ -75,13 +81,12 @@ if (process.env.NODE_ENV !== 'production') {
75
81
  }
76
82
  }
77
83
 
78
- initProxy = function initProxy (vm) {
84
+ initProxy = function initProxy(vm) {
79
85
  if (hasProxy) {
80
86
  // determine which proxy handler to use
81
87
  const options = vm.$options
82
- const handlers = options.render && options.render._withStripped
83
- ? getHandler
84
- : hasHandler
88
+ const handlers =
89
+ options.render && options.render._withStripped ? getHandler : hasHandler
85
90
  vm._renderProxy = new Proxy(vm, handlers)
86
91
  } else {
87
92
  vm._renderProxy = vm
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
4
2
  // For example, the following template:
5
3
  //
@@ -11,12 +9,15 @@
11
9
 
12
10
  import { warn } from 'core/util/debug'
13
11
 
14
- export function bindDynamicKeys (baseObj: Object, values: Array<any>): Object {
12
+ export function bindDynamicKeys(
13
+ baseObj: Record<string, any>,
14
+ values: Array<any>
15
+ ): Object {
15
16
  for (let i = 0; i < values.length; i += 2) {
16
17
  const key = values[i]
17
18
  if (typeof key === 'string' && key) {
18
19
  baseObj[values[i]] = values[i + 1]
19
- } else if (process.env.NODE_ENV !== 'production' && key !== '' && key !== null) {
20
+ } else if (__DEV__ && key !== '' && key !== null) {
20
21
  // null is a special value for explicitly removing a binding
21
22
  warn(
22
23
  `Invalid value for dynamic directive argument (expected string or null): ${key}`,
@@ -30,6 +31,6 @@ export function bindDynamicKeys (baseObj: Object, values: Array<any>): Object {
30
31
  // helper to dynamically append modifier runtime markers to event names.
31
32
  // ensure only append when value is already string, otherwise it will be cast
32
33
  // to string and cause the type check to miss.
33
- export function prependModifier (value: any, symbol: string): any {
34
+ export function prependModifier(value: any, symbol: string): any {
34
35
  return typeof value === 'string' ? symbol + value : value
35
36
  }
@@ -1,16 +1,12 @@
1
- /* @flow */
2
-
3
1
  import { warn, extend, isPlainObject } from 'core/util/index'
2
+ import type { VNodeData } from 'types/vnode'
4
3
 
5
- export function bindObjectListeners (data: any, value: any): VNodeData {
4
+ export function bindObjectListeners(data: any, value: any): VNodeData {
6
5
  if (value) {
7
6
  if (!isPlainObject(value)) {
8
- process.env.NODE_ENV !== 'production' && warn(
9
- 'v-on without argument expects an Object value',
10
- this
11
- )
7
+ __DEV__ && warn('v-on without argument expects an Object value', this)
12
8
  } else {
13
- const on = data.on = data.on ? extend({}, data.on) : {}
9
+ const on = (data.on = data.on ? extend({}, data.on) : {})
14
10
  for (const key in value) {
15
11
  const existing = on[key]
16
12
  const ours = value[key]
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import config from 'core/config'
4
2
 
5
3
  import {
@@ -8,13 +6,15 @@ import {
8
6
  toObject,
9
7
  isReservedAttribute,
10
8
  camelize,
11
- hyphenate
9
+ hyphenate,
10
+ isArray
12
11
  } from 'core/util/index'
12
+ import type { VNodeData } from 'types/vnode'
13
13
 
14
14
  /**
15
15
  * Runtime helper for merging v-bind="object" into a VNode's data.
16
16
  */
17
- export function bindObjectProps (
17
+ export function bindObjectProps(
18
18
  data: any,
19
19
  tag: string,
20
20
  value: any,
@@ -23,27 +23,22 @@ export function bindObjectProps (
23
23
  ): VNodeData {
24
24
  if (value) {
25
25
  if (!isObject(value)) {
26
- process.env.NODE_ENV !== 'production' && warn(
27
- 'v-bind without argument expects an Object or Array value',
28
- this
29
- )
26
+ __DEV__ &&
27
+ warn('v-bind without argument expects an Object or Array value', this)
30
28
  } else {
31
- if (Array.isArray(value)) {
29
+ if (isArray(value)) {
32
30
  value = toObject(value)
33
31
  }
34
32
  let hash
35
33
  for (const key in value) {
36
- if (
37
- key === 'class' ||
38
- key === 'style' ||
39
- isReservedAttribute(key)
40
- ) {
34
+ if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
41
35
  hash = data
42
36
  } else {
43
37
  const type = data.attrs && data.attrs.type
44
- hash = asProp || config.mustUseProp(tag, type, key)
45
- ? data.domProps || (data.domProps = {})
46
- : data.attrs || (data.attrs = {})
38
+ hash =
39
+ asProp || config.mustUseProp(tag, type, key)
40
+ ? data.domProps || (data.domProps = {})
41
+ : data.attrs || (data.attrs = {})
47
42
  }
48
43
  const camelizedKey = camelize(key)
49
44
  const hyphenatedKey = hyphenate(key)
@@ -1,10 +1,8 @@
1
- /* @flow */
2
-
3
1
  import config from 'core/config'
4
- import { hyphenate } from 'shared/util'
2
+ import { hyphenate, isArray } from 'shared/util'
5
3
 
6
- function isKeyNotMatch<T> (expect: T | Array<T>, actual: T): boolean {
7
- if (Array.isArray(expect)) {
4
+ function isKeyNotMatch<T>(expect: T | Array<T>, actual: T): boolean {
5
+ if (isArray(expect)) {
8
6
  return expect.indexOf(actual) === -1
9
7
  } else {
10
8
  return expect !== actual
@@ -16,13 +14,13 @@ function isKeyNotMatch<T> (expect: T | Array<T>, actual: T): boolean {
16
14
  * exposed as Vue.prototype._k
17
15
  * passing in eventKeyName as last argument separately for backwards compat
18
16
  */
19
- export function checkKeyCodes (
17
+ export function checkKeyCodes(
20
18
  eventKeyCode: number,
21
19
  key: string,
22
20
  builtInKeyCode?: number | Array<number>,
23
21
  eventKeyName?: string,
24
22
  builtInKeyName?: string | Array<string>
25
- ): ?boolean {
23
+ ): boolean | null | undefined {
26
24
  const mappedKeyCode = config.keyCodes[key] || builtInKeyCode
27
25
  if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
28
26
  return isKeyNotMatch(builtInKeyName, eventKeyName)
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import { toNumber, toString, looseEqual, looseIndexOf } from 'shared/util'
4
2
  import { createTextVNode, createEmptyVNode } from 'core/vdom/vnode'
5
3
  import { renderList } from './render-list'
@@ -12,7 +10,7 @@ import { bindObjectListeners } from './bind-object-listeners'
12
10
  import { resolveScopedSlots } from './resolve-scoped-slots'
13
11
  import { bindDynamicKeys, prependModifier } from './bind-dynamic-keys'
14
12
 
15
- export function installRenderHelpers (target: any) {
13
+ export function installRenderHelpers(target: any) {
16
14
  target._o = markOnce
17
15
  target._n = toNumber
18
16
  target._s = toString
@@ -1,20 +1,19 @@
1
- /* @flow */
2
-
3
- import { isObject, isDef, hasSymbol } from 'core/util/index'
1
+ import { isObject, isDef, hasSymbol, isArray } from 'core/util/index'
2
+ import VNode from 'core/vdom/vnode'
4
3
 
5
4
  /**
6
5
  * Runtime helper for rendering v-for lists.
7
6
  */
8
- export function renderList (
7
+ export function renderList(
9
8
  val: any,
10
- render: (
11
- val: any,
12
- keyOrIndex: string | number,
13
- index?: number
14
- ) => VNode
15
- ): ?Array<VNode> {
16
- let ret: ?Array<VNode>, i, l, keys, key
17
- if (Array.isArray(val) || typeof val === 'string') {
9
+ render: (val: any, keyOrIndex: string | number, index?: number) => VNode
10
+ ): Array<VNode> | null {
11
+ let ret: Array<VNode> | null = null,
12
+ i,
13
+ l,
14
+ keys,
15
+ key
16
+ if (isArray(val) || typeof val === 'string') {
18
17
  ret = new Array(val.length)
19
18
  for (i = 0, l = val.length; i < l; i++) {
20
19
  ret[i] = render(val[i], i)
@@ -45,6 +44,6 @@ export function renderList (
45
44
  if (!isDef(ret)) {
46
45
  ret = []
47
46
  }
48
- (ret: any)._isVList = true
47
+ ;(ret as any)._isVList = true
49
48
  return ret
50
49
  }
@@ -1,34 +1,33 @@
1
- /* @flow */
2
-
3
- import { extend, warn, isObject } from 'core/util/index'
1
+ import { extend, warn, isObject, isFunction } from 'core/util/index'
2
+ import VNode from 'core/vdom/vnode'
4
3
 
5
4
  /**
6
5
  * Runtime helper for rendering <slot>
7
6
  */
8
- export function renderSlot (
7
+ export function renderSlot(
9
8
  name: string,
10
- fallbackRender: ?((() => Array<VNode>) | Array<VNode>),
11
- props: ?Object,
12
- bindObject: ?Object
13
- ): ?Array<VNode> {
9
+ fallbackRender: ((() => Array<VNode>) | Array<VNode>) | null,
10
+ props: Record<string, any> | null,
11
+ bindObject: object | null
12
+ ): Array<VNode> | null {
14
13
  const scopedSlotFn = this.$scopedSlots[name]
15
14
  let nodes
16
15
  if (scopedSlotFn) {
17
16
  // scoped slot
18
17
  props = props || {}
19
18
  if (bindObject) {
20
- if (process.env.NODE_ENV !== 'production' && !isObject(bindObject)) {
19
+ if (__DEV__ && !isObject(bindObject)) {
21
20
  warn('slot v-bind without argument expects an Object', this)
22
21
  }
23
22
  props = extend(extend({}, bindObject), props)
24
23
  }
25
24
  nodes =
26
25
  scopedSlotFn(props) ||
27
- (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender)
26
+ (isFunction(fallbackRender) ? fallbackRender() : fallbackRender)
28
27
  } else {
29
28
  nodes =
30
29
  this.$slots[name] ||
31
- (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender)
30
+ (isFunction(fallbackRender) ? fallbackRender() : fallbackRender)
32
31
  }
33
32
 
34
33
  const target = props && props.slot
@@ -1,9 +1,10 @@
1
- /* @flow */
1
+ import VNode from 'core/vdom/vnode'
2
+ import { isArray } from 'core/util'
2
3
 
3
4
  /**
4
5
  * Runtime helper for rendering static trees.
5
6
  */
6
- export function renderStatic (
7
+ export function renderStatic(
7
8
  index: number,
8
9
  isInFor: boolean
9
10
  ): VNode | Array<VNode> {
@@ -28,7 +29,7 @@ export function renderStatic (
28
29
  * Runtime helper for v-once.
29
30
  * Effectively it means marking the node as static with a unique key.
30
31
  */
31
- export function markOnce (
32
+ export function markOnce(
32
33
  tree: VNode | Array<VNode>,
33
34
  index: number,
34
35
  key: string
@@ -37,12 +38,8 @@ export function markOnce (
37
38
  return tree
38
39
  }
39
40
 
40
- function markStatic (
41
- tree: VNode | Array<VNode>,
42
- key: string,
43
- isOnce: boolean
44
- ) {
45
- if (Array.isArray(tree)) {
41
+ function markStatic(tree: VNode | Array<VNode>, key: string, isOnce: boolean) {
42
+ if (isArray(tree)) {
46
43
  for (let i = 0; i < tree.length; i++) {
47
44
  if (tree[i] && typeof tree[i] !== 'string') {
48
45
  markStaticNode(tree[i], `${key}_${i}`, isOnce)
@@ -53,7 +50,7 @@ function markStatic (
53
50
  }
54
51
  }
55
52
 
56
- function markStaticNode (node, key, isOnce) {
53
+ function markStaticNode(node, key, isOnce) {
57
54
  node.isStatic = true
58
55
  node.key = key
59
56
  node.isOnce = isOnce
@@ -1,10 +1,8 @@
1
- /* @flow */
2
-
3
1
  import { identity, resolveAsset } from 'core/util/index'
4
2
 
5
3
  /**
6
4
  * Runtime helper for resolving filters
7
5
  */
8
- export function resolveFilter (id: string): Function {
6
+ export function resolveFilter(id: string): Function {
9
7
  return resolveAsset(this.$options, 'filters', id, true) || identity
10
8
  }
@@ -1,27 +1,30 @@
1
- /* @flow */
1
+ import type { ScopedSlotsData } from 'types/vnode'
2
+ import { isArray } from 'core/util'
2
3
 
3
- export function resolveScopedSlots (
4
- fns: ScopedSlotsData, // see flow/vnode
5
- res?: Object,
4
+ export function resolveScopedSlots(
5
+ fns: ScopedSlotsData,
6
+ res?: Record<string, any>,
6
7
  // the following are added in 2.6
7
8
  hasDynamicKeys?: boolean,
8
9
  contentHashKey?: number
9
- ): { [key: string]: Function, $stable: boolean } {
10
+ ): { $stable: boolean } & { [key: string]: Function } {
10
11
  res = res || { $stable: !hasDynamicKeys }
11
12
  for (let i = 0; i < fns.length; i++) {
12
13
  const slot = fns[i]
13
- if (Array.isArray(slot)) {
14
+ if (isArray(slot)) {
14
15
  resolveScopedSlots(slot, res, hasDynamicKeys)
15
16
  } else if (slot) {
16
17
  // marker for reverse proxying v-slot without scope on this.$slots
18
+ // @ts-expect-error
17
19
  if (slot.proxy) {
20
+ // @ts-expect-error
18
21
  slot.fn.proxy = true
19
22
  }
20
23
  res[slot.key] = slot.fn
21
24
  }
22
25
  }
23
26
  if (contentHashKey) {
24
- (res: any).$key = contentHashKey
27
+ ;(res as any).$key = contentHashKey
25
28
  }
26
- return res
29
+ return res as any
27
30
  }
@@ -1,18 +1,17 @@
1
- /* @flow */
2
-
3
1
  import type VNode from 'core/vdom/vnode'
2
+ import type { Component } from 'types/component'
4
3
 
5
4
  /**
6
5
  * Runtime helper for resolving raw children VNodes into a slot object.
7
6
  */
8
- export function resolveSlots (
9
- children: ?Array<VNode>,
10
- context: ?Component
7
+ export function resolveSlots(
8
+ children: Array<VNode> | null | undefined,
9
+ context: Component | null
11
10
  ): { [key: string]: Array<VNode> } {
12
11
  if (!children || !children.length) {
13
12
  return {}
14
13
  }
15
- const slots = {}
14
+ const slots: Record<string, any> = {}
16
15
  for (let i = 0, l = children.length; i < l; i++) {
17
16
  const child = children[i]
18
17
  const data = child.data
@@ -22,18 +21,20 @@ export function resolveSlots (
22
21
  }
23
22
  // named slots should only be respected if the vnode was rendered in the
24
23
  // same context.
25
- if ((child.context === context || child.fnContext === context) &&
26
- data && data.slot != null
24
+ if (
25
+ (child.context === context || child.fnContext === context) &&
26
+ data &&
27
+ data.slot != null
27
28
  ) {
28
29
  const name = data.slot
29
- const slot = (slots[name] || (slots[name] = []))
30
+ const slot = slots[name] || (slots[name] = [])
30
31
  if (child.tag === 'template') {
31
32
  slot.push.apply(slot, child.children || [])
32
33
  } else {
33
34
  slot.push(child)
34
35
  }
35
36
  } else {
36
- (slots.default || (slots.default = [])).push(child)
37
+ ;(slots.default || (slots.default = [])).push(child)
37
38
  }
38
39
  }
39
40
  // ignore slots that contains only whitespace
@@ -45,6 +46,6 @@ export function resolveSlots (
45
46
  return slots
46
47
  }
47
48
 
48
- function isWhitespace (node: VNode): boolean {
49
+ function isWhitespace(node: VNode): boolean {
49
50
  return (node.isComment && !node.asyncFactory) || node.text === ' '
50
51
  }