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
@@ -1,10 +1,10 @@
1
- /* @flow */
2
-
3
1
  import { inBrowser, isIE9 } from 'core/util/index'
4
- import { addClass, removeClass } from './class-util'
2
+ import { addClass, removeClass } from 'web/runtime/class-util'
5
3
  import { remove, extend, cached } from 'shared/util'
6
4
 
7
- export function resolveTransition (def?: string | Object): ?Object {
5
+ export function resolveTransition(
6
+ def?: string | Record<string, any>
7
+ ): Record<string, any> | undefined {
8
8
  if (!def) {
9
9
  return
10
10
  }
@@ -43,13 +43,15 @@ export let animationProp = 'animation'
43
43
  export let animationEndEvent = 'animationend'
44
44
  if (hasTransition) {
45
45
  /* istanbul ignore if */
46
- if (window.ontransitionend === undefined &&
46
+ if (
47
+ window.ontransitionend === undefined &&
47
48
  window.onwebkittransitionend !== undefined
48
49
  ) {
49
50
  transitionProp = 'WebkitTransition'
50
51
  transitionEndEvent = 'webkitTransitionEnd'
51
52
  }
52
- if (window.onanimationend === undefined &&
53
+ if (
54
+ window.onanimationend === undefined &&
53
55
  window.onwebkitanimationend !== undefined
54
56
  ) {
55
57
  animationProp = 'WebkitAnimation'
@@ -64,35 +66,38 @@ const raf = inBrowser
64
66
  : setTimeout
65
67
  : /* istanbul ignore next */ fn => fn()
66
68
 
67
- export function nextFrame (fn: Function) {
69
+ export function nextFrame(fn: Function) {
68
70
  raf(() => {
71
+ // @ts-expect-error
69
72
  raf(fn)
70
73
  })
71
74
  }
72
75
 
73
- export function addTransitionClass (el: any, cls: string) {
74
- const transitionClasses = el._transitionClasses || (el._transitionClasses = [])
76
+ export function addTransitionClass(el: any, cls: string) {
77
+ const transitionClasses =
78
+ el._transitionClasses || (el._transitionClasses = [])
75
79
  if (transitionClasses.indexOf(cls) < 0) {
76
80
  transitionClasses.push(cls)
77
81
  addClass(el, cls)
78
82
  }
79
83
  }
80
84
 
81
- export function removeTransitionClass (el: any, cls: string) {
85
+ export function removeTransitionClass(el: any, cls: string) {
82
86
  if (el._transitionClasses) {
83
87
  remove(el._transitionClasses, cls)
84
88
  }
85
89
  removeClass(el, cls)
86
90
  }
87
91
 
88
- export function whenTransitionEnds (
92
+ export function whenTransitionEnds(
89
93
  el: Element,
90
- expectedType: ?string,
94
+ expectedType: string | undefined,
91
95
  cb: Function
92
96
  ) {
93
97
  const { type, timeout, propCount } = getTransitionInfo(el, expectedType)
94
98
  if (!type) return cb()
95
- const event: string = type === TRANSITION ? transitionEndEvent : animationEndEvent
99
+ const event: string =
100
+ type === TRANSITION ? transitionEndEvent : animationEndEvent
96
101
  let ended = 0
97
102
  const end = () => {
98
103
  el.removeEventListener(event, onEnd)
@@ -115,22 +120,39 @@ export function whenTransitionEnds (
115
120
 
116
121
  const transformRE = /\b(transform|all)(,|$)/
117
122
 
118
- export function getTransitionInfo (el: Element, expectedType?: ?string): {
119
- type: ?string;
120
- propCount: number;
121
- timeout: number;
122
- hasTransform: boolean;
123
+ export function getTransitionInfo(
124
+ el: Element,
125
+ expectedType?: string
126
+ ): {
127
+ type?: string | null
128
+ propCount: number
129
+ timeout: number
130
+ hasTransform: boolean
123
131
  } {
124
132
  const styles: any = window.getComputedStyle(el)
125
133
  // JSDOM may return undefined for transition properties
126
- const transitionDelays: Array<string> = (styles[transitionProp + 'Delay'] || '').split(', ')
127
- const transitionDurations: Array<string> = (styles[transitionProp + 'Duration'] || '').split(', ')
128
- const transitionTimeout: number = getTimeout(transitionDelays, transitionDurations)
129
- const animationDelays: Array<string> = (styles[animationProp + 'Delay'] || '').split(', ')
130
- const animationDurations: Array<string> = (styles[animationProp + 'Duration'] || '').split(', ')
131
- const animationTimeout: number = getTimeout(animationDelays, animationDurations)
132
-
133
- let type: ?string
134
+ const transitionDelays: Array<string> = (
135
+ styles[transitionProp + 'Delay'] || ''
136
+ ).split(', ')
137
+ const transitionDurations: Array<string> = (
138
+ styles[transitionProp + 'Duration'] || ''
139
+ ).split(', ')
140
+ const transitionTimeout: number = getTimeout(
141
+ transitionDelays,
142
+ transitionDurations
143
+ )
144
+ const animationDelays: Array<string> = (
145
+ styles[animationProp + 'Delay'] || ''
146
+ ).split(', ')
147
+ const animationDurations: Array<string> = (
148
+ styles[animationProp + 'Duration'] || ''
149
+ ).split(', ')
150
+ const animationTimeout: number = getTimeout(
151
+ animationDelays,
152
+ animationDurations
153
+ )
154
+
155
+ let type: string | undefined | null
134
156
  let timeout = 0
135
157
  let propCount = 0
136
158
  /* istanbul ignore if */
@@ -148,11 +170,12 @@ export function getTransitionInfo (el: Element, expectedType?: ?string): {
148
170
  }
149
171
  } else {
150
172
  timeout = Math.max(transitionTimeout, animationTimeout)
151
- type = timeout > 0
152
- ? transitionTimeout > animationTimeout
153
- ? TRANSITION
154
- : ANIMATION
155
- : null
173
+ type =
174
+ timeout > 0
175
+ ? transitionTimeout > animationTimeout
176
+ ? TRANSITION
177
+ : ANIMATION
178
+ : null
156
179
  propCount = type
157
180
  ? type === TRANSITION
158
181
  ? transitionDurations.length
@@ -160,8 +183,7 @@ export function getTransitionInfo (el: Element, expectedType?: ?string): {
160
183
  : 0
161
184
  }
162
185
  const hasTransform: boolean =
163
- type === TRANSITION &&
164
- transformRE.test(styles[transitionProp + 'Property'])
186
+ type === TRANSITION && transformRE.test(styles[transitionProp + 'Property'])
165
187
  return {
166
188
  type,
167
189
  timeout,
@@ -170,21 +192,24 @@ export function getTransitionInfo (el: Element, expectedType?: ?string): {
170
192
  }
171
193
  }
172
194
 
173
- function getTimeout (delays: Array<string>, durations: Array<string>): number {
195
+ function getTimeout(delays: Array<string>, durations: Array<string>): number {
174
196
  /* istanbul ignore next */
175
197
  while (delays.length < durations.length) {
176
198
  delays = delays.concat(delays)
177
199
  }
178
200
 
179
- return Math.max.apply(null, durations.map((d, i) => {
180
- return toMs(d) + toMs(delays[i])
181
- }))
201
+ return Math.max.apply(
202
+ null,
203
+ durations.map((d, i) => {
204
+ return toMs(d) + toMs(delays[i])
205
+ })
206
+ )
182
207
  }
183
208
 
184
209
  // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
185
210
  // in a locale-dependent way, using a comma instead of a dot.
186
211
  // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
187
212
  // as a floor function) causing unexpected behaviors
188
- function toMs (s: string): number {
213
+ function toMs(s: string): number {
189
214
  return Number(s.slice(0, -1).replace(',', '.')) * 1000
190
215
  }
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import config from 'core/config'
4
2
  import { warn, cached } from 'core/util/index'
5
3
  import { mark, measure } from 'core/util/perf'
@@ -7,7 +5,12 @@ import { mark, measure } from 'core/util/perf'
7
5
  import Vue from './runtime/index'
8
6
  import { query } from './util/index'
9
7
  import { compileToFunctions } from './compiler/index'
10
- import { shouldDecodeNewlines, shouldDecodeNewlinesForHref } from './util/compat'
8
+ import {
9
+ shouldDecodeNewlines,
10
+ shouldDecodeNewlinesForHref
11
+ } from './util/compat'
12
+ import type { Component } from 'types/component'
13
+ import type { GlobalAPI } from 'types/global-api'
11
14
 
12
15
  const idToTemplate = cached(id => {
13
16
  const el = query(id)
@@ -23,9 +26,10 @@ Vue.prototype.$mount = function (
23
26
 
24
27
  /* istanbul ignore if */
25
28
  if (el === document.body || el === document.documentElement) {
26
- process.env.NODE_ENV !== 'production' && warn(
27
- `Do not mount Vue to <html> or <body> - mount to normal elements instead.`
28
- )
29
+ __DEV__ &&
30
+ warn(
31
+ `Do not mount Vue to <html> or <body> - mount to normal elements instead.`
32
+ )
29
33
  return this
30
34
  }
31
35
 
@@ -38,7 +42,7 @@ Vue.prototype.$mount = function (
38
42
  if (template.charAt(0) === '#') {
39
43
  template = idToTemplate(template)
40
44
  /* istanbul ignore if */
41
- if (process.env.NODE_ENV !== 'production' && !template) {
45
+ if (__DEV__ && !template) {
42
46
  warn(
43
47
  `Template element not found or is empty: ${options.template}`,
44
48
  this
@@ -48,32 +52,37 @@ Vue.prototype.$mount = function (
48
52
  } else if (template.nodeType) {
49
53
  template = template.innerHTML
50
54
  } else {
51
- if (process.env.NODE_ENV !== 'production') {
55
+ if (__DEV__) {
52
56
  warn('invalid template option:' + template, this)
53
57
  }
54
58
  return this
55
59
  }
56
60
  } else if (el) {
61
+ // @ts-expect-error
57
62
  template = getOuterHTML(el)
58
63
  }
59
64
  if (template) {
60
65
  /* istanbul ignore if */
61
- if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
66
+ if (__DEV__ && config.performance && mark) {
62
67
  mark('compile')
63
68
  }
64
69
 
65
- const { render, staticRenderFns } = compileToFunctions(template, {
66
- outputSourceRange: process.env.NODE_ENV !== 'production',
67
- shouldDecodeNewlines,
68
- shouldDecodeNewlinesForHref,
69
- delimiters: options.delimiters,
70
- comments: options.comments
71
- }, this)
70
+ const { render, staticRenderFns } = compileToFunctions(
71
+ template,
72
+ {
73
+ outputSourceRange: __DEV__,
74
+ shouldDecodeNewlines,
75
+ shouldDecodeNewlinesForHref,
76
+ delimiters: options.delimiters,
77
+ comments: options.comments
78
+ },
79
+ this
80
+ )
72
81
  options.render = render
73
82
  options.staticRenderFns = staticRenderFns
74
83
 
75
84
  /* istanbul ignore if */
76
- if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
85
+ if (__DEV__ && config.performance && mark) {
77
86
  mark('compile end')
78
87
  measure(`vue ${this._name} compile`, 'compile', 'compile end')
79
88
  }
@@ -86,7 +95,7 @@ Vue.prototype.$mount = function (
86
95
  * Get outerHTML of elements, taking care
87
96
  * of SVG elements in IE as well.
88
97
  */
89
- function getOuterHTML (el: Element): string {
98
+ function getOuterHTML(el: Element): string {
90
99
  if (el.outerHTML) {
91
100
  return el.outerHTML
92
101
  } else {
@@ -98,4 +107,4 @@ function getOuterHTML (el: Element): string {
98
107
 
99
108
  Vue.compile = compileToFunctions
100
109
 
101
- export default Vue
110
+ export default Vue as GlobalAPI
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import { makeMap } from 'shared/util'
4
2
 
5
3
  // these are reserved for web because they are directly compiled away
@@ -8,9 +6,13 @@ export const isReservedAttr = makeMap('style,class')
8
6
 
9
7
  // attributes that should be using props for binding
10
8
  const acceptValue = makeMap('input,textarea,option,select,progress')
11
- export const mustUseProp = (tag: string, type: ?string, attr: string): boolean => {
9
+ export const mustUseProp = (
10
+ tag: string,
11
+ type?: string | null,
12
+ attr?: string
13
+ ): boolean => {
12
14
  return (
13
- (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
15
+ (attr === 'value' && acceptValue(tag) && type !== 'button') ||
14
16
  (attr === 'selected' && tag === 'option') ||
15
17
  (attr === 'checked' && tag === 'input') ||
16
18
  (attr === 'muted' && tag === 'video')
@@ -19,24 +21,26 @@ export const mustUseProp = (tag: string, type: ?string, attr: string): boolean =
19
21
 
20
22
  export const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck')
21
23
 
22
- const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only')
24
+ const isValidContentEditableValue = makeMap(
25
+ 'events,caret,typing,plaintext-only'
26
+ )
23
27
 
24
28
  export const convertEnumeratedValue = (key: string, value: any) => {
25
29
  return isFalsyAttrValue(value) || value === 'false'
26
30
  ? 'false'
27
- // allow arbitrary string value for contenteditable
28
- : key === 'contenteditable' && isValidContentEditableValue(value)
29
- ? value
30
- : 'true'
31
+ : // allow arbitrary string value for contenteditable
32
+ key === 'contenteditable' && isValidContentEditableValue(value)
33
+ ? value
34
+ : 'true'
31
35
  }
32
36
 
33
37
  export const isBooleanAttr = makeMap(
34
38
  'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
35
- 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
36
- 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
37
- 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
38
- 'required,reversed,scoped,seamless,selected,sortable,' +
39
- 'truespeed,typemustmatch,visible'
39
+ 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
40
+ 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
41
+ 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
42
+ 'required,reversed,scoped,seamless,selected,sortable,' +
43
+ 'truespeed,typemustmatch,visible'
40
44
  )
41
45
 
42
46
  export const xlinkNS = 'http://www.w3.org/1999/xlink'
@@ -1,39 +1,41 @@
1
- /* @flow */
2
-
1
+ import VNode from 'core/vdom/vnode'
3
2
  import { isDef, isObject } from 'shared/util'
3
+ import type { VNodeData, VNodeWithData } from 'types/vnode'
4
4
 
5
- export function genClassForVnode (vnode: VNodeWithData): string {
5
+ export function genClassForVnode(vnode: VNodeWithData): string {
6
6
  let data = vnode.data
7
- let parentNode = vnode
8
- let childNode = vnode
7
+ let parentNode: VNode | VNodeWithData | undefined = vnode
8
+ let childNode: VNode | VNodeWithData = vnode
9
9
  while (isDef(childNode.componentInstance)) {
10
- childNode = childNode.componentInstance._vnode
10
+ childNode = childNode.componentInstance._vnode!
11
11
  if (childNode && childNode.data) {
12
12
  data = mergeClassData(childNode.data, data)
13
13
  }
14
14
  }
15
- while (isDef(parentNode = parentNode.parent)) {
15
+ // @ts-expect-error parentNode.parent not VNodeWithData
16
+ while (isDef((parentNode = parentNode.parent))) {
16
17
  if (parentNode && parentNode.data) {
17
18
  data = mergeClassData(data, parentNode.data)
18
19
  }
19
20
  }
20
- return renderClass(data.staticClass, data.class)
21
+ return renderClass(data.staticClass!, data.class)
21
22
  }
22
23
 
23
- function mergeClassData (child: VNodeData, parent: VNodeData): {
24
- staticClass: string,
24
+ function mergeClassData(
25
+ child: VNodeData,
26
+ parent: VNodeData
27
+ ): {
28
+ staticClass: string
25
29
  class: any
26
30
  } {
27
31
  return {
28
32
  staticClass: concat(child.staticClass, parent.staticClass),
29
- class: isDef(child.class)
30
- ? [child.class, parent.class]
31
- : parent.class
33
+ class: isDef(child.class) ? [child.class, parent.class] : parent.class
32
34
  }
33
35
  }
34
36
 
35
- export function renderClass (
36
- staticClass: ?string,
37
+ export function renderClass(
38
+ staticClass: string | null | undefined,
37
39
  dynamicClass: any
38
40
  ): string {
39
41
  if (isDef(staticClass) || isDef(dynamicClass)) {
@@ -43,11 +45,11 @@ export function renderClass (
43
45
  return ''
44
46
  }
45
47
 
46
- export function concat (a: ?string, b: ?string): string {
47
- return a ? b ? (a + ' ' + b) : a : (b || '')
48
+ export function concat(a?: string | null, b?: string | null): string {
49
+ return a ? (b ? a + ' ' + b : a) : b || ''
48
50
  }
49
51
 
50
- export function stringifyClass (value: any): string {
52
+ export function stringifyClass(value: any): string {
51
53
  if (Array.isArray(value)) {
52
54
  return stringifyArray(value)
53
55
  }
@@ -61,11 +63,11 @@ export function stringifyClass (value: any): string {
61
63
  return ''
62
64
  }
63
65
 
64
- function stringifyArray (value: Array<any>): string {
66
+ function stringifyArray(value: Array<any>): string {
65
67
  let res = ''
66
68
  let stringified
67
69
  for (let i = 0, l = value.length; i < l; i++) {
68
- if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
70
+ if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
69
71
  if (res) res += ' '
70
72
  res += stringified
71
73
  }
@@ -73,7 +75,7 @@ function stringifyArray (value: Array<any>): string {
73
75
  return res
74
76
  }
75
77
 
76
- function stringifyObject (value: Object): string {
78
+ function stringifyObject(value: Object): string {
77
79
  let res = ''
78
80
  for (const key in value) {
79
81
  if (value[key]) {
@@ -1,10 +1,8 @@
1
- /* @flow */
2
-
3
1
  import { inBrowser } from 'core/util/index'
4
2
 
5
3
  // check whether current browser encodes a char inside attribute values
6
4
  let div
7
- function getShouldDecode (href: boolean): boolean {
5
+ function getShouldDecode(href: boolean): boolean {
8
6
  div = div || document.createElement('div')
9
7
  div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`
10
8
  return div.innerHTML.indexOf('&#10;') > 0
@@ -13,4 +11,6 @@ function getShouldDecode (href: boolean): boolean {
13
11
  // #3663: IE encodes newlines inside attribute values while other browsers don't
14
12
  export const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false
15
13
  // #6828: chrome encodes content in a[href]
16
- export const shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false
14
+ export const shouldDecodeNewlinesForHref = inBrowser
15
+ ? getShouldDecode(true)
16
+ : false
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import { inBrowser } from 'core/util/env'
4
2
  import { makeMap } from 'shared/util'
5
3
 
@@ -10,34 +8,34 @@ export const namespaceMap = {
10
8
 
11
9
  export const isHTMLTag = makeMap(
12
10
  'html,body,base,head,link,meta,style,title,' +
13
- 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
14
- 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
15
- 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
16
- 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
17
- 'embed,object,param,source,canvas,script,noscript,del,ins,' +
18
- 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
19
- 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
20
- 'output,progress,select,textarea,' +
21
- 'details,dialog,menu,menuitem,summary,' +
22
- 'content,element,shadow,template,blockquote,iframe,tfoot'
11
+ 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
12
+ 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
13
+ 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
14
+ 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
15
+ 'embed,object,param,source,canvas,script,noscript,del,ins,' +
16
+ 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
17
+ 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
18
+ 'output,progress,select,textarea,' +
19
+ 'details,dialog,menu,menuitem,summary,' +
20
+ 'content,element,shadow,template,blockquote,iframe,tfoot'
23
21
  )
24
22
 
25
23
  // this map is intentionally selective, only covering SVG elements that may
26
24
  // contain child elements.
27
25
  export const isSVG = makeMap(
28
26
  'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
29
- 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
30
- 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
27
+ 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
28
+ 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
31
29
  true
32
30
  )
33
31
 
34
- export const isPreTag = (tag: ?string): boolean => tag === 'pre'
32
+ export const isPreTag = (tag?: string): boolean => tag === 'pre'
35
33
 
36
- export const isReservedTag = (tag: string): ?boolean => {
34
+ export const isReservedTag = (tag: string): boolean | undefined => {
37
35
  return isHTMLTag(tag) || isSVG(tag)
38
36
  }
39
37
 
40
- export function getTagNamespace (tag: string): ?string {
38
+ export function getTagNamespace(tag: string): string | undefined {
41
39
  if (isSVG(tag)) {
42
40
  return 'svg'
43
41
  }
@@ -49,7 +47,7 @@ export function getTagNamespace (tag: string): ?string {
49
47
  }
50
48
 
51
49
  const unknownElementCache = Object.create(null)
52
- export function isUnknownElement (tag: string): boolean {
50
+ export function isUnknownElement(tag: string): boolean {
53
51
  /* istanbul ignore if */
54
52
  if (!inBrowser) {
55
53
  return true
@@ -65,13 +63,14 @@ export function isUnknownElement (tag: string): boolean {
65
63
  const el = document.createElement(tag)
66
64
  if (tag.indexOf('-') > -1) {
67
65
  // http://stackoverflow.com/a/28210364/1070244
68
- return (unknownElementCache[tag] = (
66
+ return (unknownElementCache[tag] =
69
67
  el.constructor === window.HTMLUnknownElement ||
70
- el.constructor === window.HTMLElement
71
- ))
68
+ el.constructor === window.HTMLElement)
72
69
  } else {
73
70
  return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
74
71
  }
75
72
  }
76
73
 
77
- export const isTextInputType = makeMap('text,number,password,search,email,tel,url')
74
+ export const isTextInputType = makeMap(
75
+ 'text,number,password,search,email,tel,url'
76
+ )
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import { warn } from 'core/util/index'
4
2
 
5
3
  export * from './attrs'
@@ -9,13 +7,11 @@ export * from './element'
9
7
  /**
10
8
  * Query an element selector if it's not an element already.
11
9
  */
12
- export function query (el: string | Element): Element {
10
+ export function query(el: string | Element): Element {
13
11
  if (typeof el === 'string') {
14
12
  const selected = document.querySelector(el)
15
13
  if (!selected) {
16
- process.env.NODE_ENV !== 'production' && warn(
17
- 'Cannot find element: ' + el
18
- )
14
+ __DEV__ && warn('Cannot find element: ' + el)
19
15
  return document.createElement('div')
20
16
  }
21
17
  return selected
@@ -1,6 +1,6 @@
1
- /* @flow */
2
-
1
+ import VNode from 'core/vdom/vnode'
3
2
  import { cached, extend, toObject } from 'shared/util'
3
+ import type { VNodeData, VNodeWithData } from 'types/vnode'
4
4
 
5
5
  export const parseStyleText = cached(function (cssText) {
6
6
  const res = {}
@@ -16,17 +16,15 @@ export const parseStyleText = cached(function (cssText) {
16
16
  })
17
17
 
18
18
  // merge static and dynamic style data on the same vnode
19
- function normalizeStyleData (data: VNodeData): ?Object {
19
+ function normalizeStyleData(data: VNodeData): Record<string, any> {
20
20
  const style = normalizeStyleBinding(data.style)
21
21
  // static style is pre-processed into an object during compilation
22
22
  // and is always a fresh object, so it's safe to merge into it
23
- return data.staticStyle
24
- ? extend(data.staticStyle, style)
25
- : style
23
+ return data.staticStyle ? extend(data.staticStyle, style) : style
26
24
  }
27
25
 
28
26
  // normalize possible array / string values into Object
29
- export function normalizeStyleBinding (bindingStyle: any): ?Object {
27
+ export function normalizeStyleBinding(bindingStyle: any): Record<string, any> {
30
28
  if (Array.isArray(bindingStyle)) {
31
29
  return toObject(bindingStyle)
32
30
  }
@@ -40,16 +38,17 @@ export function normalizeStyleBinding (bindingStyle: any): ?Object {
40
38
  * parent component style should be after child's
41
39
  * so that parent component's style could override it
42
40
  */
43
- export function getStyle (vnode: VNodeWithData, checkChild: boolean): Object {
41
+ export function getStyle(vnode: VNodeWithData, checkChild: boolean): Object {
44
42
  const res = {}
45
43
  let styleData
46
44
 
47
45
  if (checkChild) {
48
- let childNode = vnode
46
+ let childNode: VNodeWithData | VNode = vnode
49
47
  while (childNode.componentInstance) {
50
- childNode = childNode.componentInstance._vnode
48
+ childNode = childNode.componentInstance._vnode!
51
49
  if (
52
- childNode && childNode.data &&
50
+ childNode &&
51
+ childNode.data &&
53
52
  (styleData = normalizeStyleData(childNode.data))
54
53
  ) {
55
54
  extend(res, styleData)
@@ -61,7 +60,8 @@ export function getStyle (vnode: VNodeWithData, checkChild: boolean): Object {
61
60
  extend(res, styleData)
62
61
  }
63
62
 
64
- let parentNode = vnode
63
+ let parentNode: VNodeWithData | VNode | undefined = vnode
64
+ // @ts-expect-error parentNode.parent not VNodeWithData
65
65
  while ((parentNode = parentNode.parent)) {
66
66
  if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
67
67
  extend(res, styleData)