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,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  // Provides transition support for list items.
4
2
  // supports move transitions using the FLIP technique.
5
3
 
@@ -12,7 +10,7 @@
12
10
  // nodes will remain where they should be.
13
11
 
14
12
  import { warn, extend } from 'core/util/index'
15
- import { addClass, removeClass } from '../class-util'
13
+ import { addClass, removeClass } from 'web/runtime/class-util'
16
14
  import { transitionProps, extractTransitionData } from './transition'
17
15
  import { setActiveInstance } from 'core/instance/lifecycle'
18
16
 
@@ -22,19 +20,24 @@ import {
22
20
  transitionEndEvent,
23
21
  addTransitionClass,
24
22
  removeTransitionClass
25
- } from '../transition-util'
26
-
27
- const props = extend({
28
- tag: String,
29
- moveClass: String
30
- }, transitionProps)
23
+ } from 'web/runtime/transition-util'
24
+ import VNode from 'core/vdom/vnode'
25
+ import { VNodeWithData } from 'types/vnode'
26
+
27
+ const props = extend(
28
+ {
29
+ tag: String,
30
+ moveClass: String
31
+ },
32
+ transitionProps
33
+ )
31
34
 
32
35
  delete props.mode
33
36
 
34
37
  export default {
35
38
  props,
36
39
 
37
- beforeMount () {
40
+ beforeMount() {
38
41
  const update = this._update
39
42
  this._update = (vnode, hydrating) => {
40
43
  const restoreActiveInstance = setActiveInstance(this)
@@ -51,13 +54,13 @@ export default {
51
54
  }
52
55
  },
53
56
 
54
- render (h: Function) {
57
+ render(h: Function) {
55
58
  const tag: string = this.tag || this.$vnode.data.tag || 'span'
56
- const map: Object = Object.create(null)
57
- const prevChildren: Array<VNode> = this.prevChildren = this.children
59
+ const map: Record<string, any> = Object.create(null)
60
+ const prevChildren: Array<VNode> = (this.prevChildren = this.children)
58
61
  const rawChildren: Array<VNode> = this.$slots.default || []
59
- const children: Array<VNode> = this.children = []
60
- const transitionData: Object = extractTransitionData(this)
62
+ const children: Array<VNode> = (this.children = [])
63
+ const transitionData = extractTransitionData(this)
61
64
 
62
65
  for (let i = 0; i < rawChildren.length; i++) {
63
66
  const c: VNode = rawChildren[i]
@@ -66,9 +69,11 @@ export default {
66
69
  children.push(c)
67
70
  map[c.key] = c
68
71
  ;(c.data || (c.data = {})).transition = transitionData
69
- } else if (process.env.NODE_ENV !== 'production') {
70
- const opts: ?VNodeComponentOptions = c.componentOptions
71
- const name: string = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag
72
+ } else if (__DEV__) {
73
+ const opts = c.componentOptions
74
+ const name: string = opts
75
+ ? opts.Ctor.options.name || opts.tag || ''
76
+ : c.tag
72
77
  warn(`<transition-group> children must be keyed: <${name}>`)
73
78
  }
74
79
  }
@@ -79,9 +84,10 @@ export default {
79
84
  const removed: Array<VNode> = []
80
85
  for (let i = 0; i < prevChildren.length; i++) {
81
86
  const c: VNode = prevChildren[i]
82
- c.data.transition = transitionData
83
- c.data.pos = c.elm.getBoundingClientRect()
84
- if (map[c.key]) {
87
+ c.data!.transition = transitionData
88
+ // @ts-expect-error .getBoundingClientRect is not typed in Node
89
+ c.data!.pos = c.elm.getBoundingClientRect()
90
+ if (map[c.key!]) {
85
91
  kept.push(c)
86
92
  } else {
87
93
  removed.push(c)
@@ -94,9 +100,9 @@ export default {
94
100
  return h(tag, null, children)
95
101
  },
96
102
 
97
- updated () {
98
- const children: Array<VNode> = this.prevChildren
99
- const moveClass: string = this.moveClass || ((this.name || 'v') + '-move')
103
+ updated() {
104
+ const children: Array<VNodeWithData> = this.prevChildren
105
+ const moveClass: string = this.moveClass || (this.name || 'v') + '-move'
100
106
  if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
101
107
  return
102
108
  }
@@ -113,27 +119,30 @@ export default {
113
119
  this._reflow = document.body.offsetHeight
114
120
 
115
121
  children.forEach((c: VNode) => {
116
- if (c.data.moved) {
122
+ if (c.data!.moved) {
117
123
  const el: any = c.elm
118
124
  const s: any = el.style
119
125
  addTransitionClass(el, moveClass)
120
126
  s.transform = s.WebkitTransform = s.transitionDuration = ''
121
- el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
122
- if (e && e.target !== el) {
123
- return
124
- }
125
- if (!e || /transform$/.test(e.propertyName)) {
126
- el.removeEventListener(transitionEndEvent, cb)
127
- el._moveCb = null
128
- removeTransitionClass(el, moveClass)
129
- }
130
- })
127
+ el.addEventListener(
128
+ transitionEndEvent,
129
+ (el._moveCb = function cb(e) {
130
+ if (e && e.target !== el) {
131
+ return
132
+ }
133
+ if (!e || /transform$/.test(e.propertyName)) {
134
+ el.removeEventListener(transitionEndEvent, cb)
135
+ el._moveCb = null
136
+ removeTransitionClass(el, moveClass)
137
+ }
138
+ })
139
+ )
131
140
  }
132
141
  })
133
142
  },
134
143
 
135
144
  methods: {
136
- hasMove (el: any, moveClass: string): boolean {
145
+ hasMove(el: any, moveClass: string): boolean {
137
146
  /* istanbul ignore if */
138
147
  if (!hasTransition) {
139
148
  return false
@@ -149,34 +158,38 @@ export default {
149
158
  // is applied.
150
159
  const clone: HTMLElement = el.cloneNode()
151
160
  if (el._transitionClasses) {
152
- el._transitionClasses.forEach((cls: string) => { removeClass(clone, cls) })
161
+ el._transitionClasses.forEach((cls: string) => {
162
+ removeClass(clone, cls)
163
+ })
153
164
  }
154
165
  addClass(clone, moveClass)
155
166
  clone.style.display = 'none'
156
167
  this.$el.appendChild(clone)
157
- const info: Object = getTransitionInfo(clone)
168
+ const info: any = getTransitionInfo(clone)
158
169
  this.$el.removeChild(clone)
159
170
  return (this._hasMove = info.hasTransform)
160
171
  }
161
172
  }
162
173
  }
163
174
 
164
- function callPendingCbs (c: VNode) {
175
+ function callPendingCbs(
176
+ c: VNodeWithData & { elm?: { _moveCb?: Function; _enterCb?: Function } }
177
+ ) {
165
178
  /* istanbul ignore if */
166
- if (c.elm._moveCb) {
167
- c.elm._moveCb()
179
+ if (c.elm!._moveCb) {
180
+ c.elm!._moveCb()
168
181
  }
169
182
  /* istanbul ignore if */
170
- if (c.elm._enterCb) {
171
- c.elm._enterCb()
183
+ if (c.elm!._enterCb) {
184
+ c.elm!._enterCb()
172
185
  }
173
186
  }
174
187
 
175
- function recordPosition (c: VNode) {
176
- c.data.newPos = c.elm.getBoundingClientRect()
188
+ function recordPosition(c: VNodeWithData) {
189
+ c.data!.newPos = c.elm.getBoundingClientRect()
177
190
  }
178
191
 
179
- function applyTranslation (c: VNode) {
192
+ function applyTranslation(c: VNodeWithData) {
180
193
  const oldPos = c.data.pos
181
194
  const newPos = c.data.newPos
182
195
  const dx = oldPos.left - newPos.left
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  // Provides transition support for a single element/component.
4
2
  // supports transition mode (out-in / in-out)
5
3
 
@@ -10,6 +8,8 @@ import {
10
8
  isAsyncPlaceholder,
11
9
  getFirstComponentChild
12
10
  } from 'core/vdom/helpers/index'
11
+ import VNode from 'core/vdom/vnode'
12
+ import type { Component } from 'types/component'
13
13
 
14
14
  export const transitionProps = {
15
15
  name: String,
@@ -31,8 +31,8 @@ export const transitionProps = {
31
31
 
32
32
  // in case the child is also an abstract component, e.g. <keep-alive>
33
33
  // we want to recursively retrieve the real component to be rendered
34
- function getRealChild (vnode: ?VNode): ?VNode {
35
- const compOptions: ?VNodeComponentOptions = vnode && vnode.componentOptions
34
+ function getRealChild(vnode?: VNode): VNode | undefined {
35
+ const compOptions = vnode && vnode.componentOptions
36
36
  if (compOptions && compOptions.Ctor.options.abstract) {
37
37
  return getRealChild(getFirstComponentChild(compOptions.children))
38
38
  } else {
@@ -40,39 +40,40 @@ function getRealChild (vnode: ?VNode): ?VNode {
40
40
  }
41
41
  }
42
42
 
43
- export function extractTransitionData (comp: Component): Object {
43
+ export function extractTransitionData(comp: Component): Record<string, any> {
44
44
  const data = {}
45
- const options: ComponentOptions = comp.$options
45
+ const options = comp.$options
46
46
  // props
47
47
  for (const key in options.propsData) {
48
48
  data[key] = comp[key]
49
49
  }
50
50
  // events.
51
51
  // extract listeners and pass them directly to the transition methods
52
- const listeners: ?Object = options._parentListeners
52
+ const listeners = options._parentListeners
53
53
  for (const key in listeners) {
54
54
  data[camelize(key)] = listeners[key]
55
55
  }
56
56
  return data
57
57
  }
58
58
 
59
- function placeholder (h: Function, rawChild: VNode): ?VNode {
59
+ function placeholder(h: Function, rawChild: VNode): VNode | undefined {
60
+ // @ts-expect-error
60
61
  if (/\d-keep-alive$/.test(rawChild.tag)) {
61
62
  return h('keep-alive', {
62
- props: rawChild.componentOptions.propsData
63
+ props: rawChild.componentOptions!.propsData
63
64
  })
64
65
  }
65
66
  }
66
67
 
67
- function hasParentTransition (vnode: VNode): ?boolean {
68
- while ((vnode = vnode.parent)) {
69
- if (vnode.data.transition) {
68
+ function hasParentTransition(vnode: VNode): boolean | undefined {
69
+ while ((vnode = vnode.parent!)) {
70
+ if (vnode.data!.transition) {
70
71
  return true
71
72
  }
72
73
  }
73
74
  }
74
75
 
75
- function isSameChild (child: VNode, oldChild: VNode): boolean {
76
+ function isSameChild(child: VNode, oldChild: VNode): boolean {
76
77
  return oldChild.key === child.key && oldChild.tag === child.tag
77
78
  }
78
79
 
@@ -85,7 +86,7 @@ export default {
85
86
  props: transitionProps,
86
87
  abstract: true,
87
88
 
88
- render (h: Function) {
89
+ render(h: Function) {
89
90
  let children: any = this.$slots.default
90
91
  if (!children) {
91
92
  return
@@ -99,10 +100,10 @@ export default {
99
100
  }
100
101
 
101
102
  // warn multiple elements
102
- if (process.env.NODE_ENV !== 'production' && children.length > 1) {
103
+ if (__DEV__ && children.length > 1) {
103
104
  warn(
104
105
  '<transition> can only be used on a single element. Use ' +
105
- '<transition-group> for lists.',
106
+ '<transition-group> for lists.',
106
107
  this.$parent
107
108
  )
108
109
  }
@@ -110,13 +111,8 @@ export default {
110
111
  const mode: string = this.mode
111
112
 
112
113
  // warn invalid mode
113
- if (process.env.NODE_ENV !== 'production' &&
114
- mode && mode !== 'in-out' && mode !== 'out-in'
115
- ) {
116
- warn(
117
- 'invalid <transition> mode: ' + mode,
118
- this.$parent
119
- )
114
+ if (__DEV__ && mode && mode !== 'in-out' && mode !== 'out-in') {
115
+ warn('invalid <transition> mode: ' + mode, this.$parent)
120
116
  }
121
117
 
122
118
  const rawChild: VNode = children[0]
@@ -129,7 +125,7 @@ export default {
129
125
 
130
126
  // apply transition data to child
131
127
  // use getRealChild() to ignore abstract components e.g. keep-alive
132
- const child: ?VNode = getRealChild(rawChild)
128
+ const child = getRealChild(rawChild)
133
129
  /* istanbul ignore if */
134
130
  if (!child) {
135
131
  return rawChild
@@ -143,17 +139,21 @@ export default {
143
139
  // component instance. This key will be used to remove pending leaving nodes
144
140
  // during entering.
145
141
  const id: string = `__transition-${this._uid}-`
146
- child.key = child.key == null
147
- ? child.isComment
148
- ? id + 'comment'
149
- : id + child.tag
150
- : isPrimitive(child.key)
151
- ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
142
+ child.key =
143
+ child.key == null
144
+ ? child.isComment
145
+ ? id + 'comment'
146
+ : id + child.tag
147
+ : isPrimitive(child.key)
148
+ ? String(child.key).indexOf(id) === 0
149
+ ? child.key
150
+ : id + child.key
152
151
  : child.key
153
152
 
154
- const data: Object = (child.data || (child.data = {})).transition = extractTransitionData(this)
153
+ const data: Object = ((child.data || (child.data = {})).transition =
154
+ extractTransitionData(this))
155
155
  const oldRawChild: VNode = this._vnode
156
- const oldChild: VNode = getRealChild(oldRawChild)
156
+ const oldChild = getRealChild(oldRawChild)
157
157
 
158
158
  // mark v-show
159
159
  // so that the transition module can hand over the control to the directive
@@ -167,11 +167,14 @@ export default {
167
167
  !isSameChild(child, oldChild) &&
168
168
  !isAsyncPlaceholder(oldChild) &&
169
169
  // #6687 component root is a comment node
170
- !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
170
+ !(
171
+ oldChild.componentInstance &&
172
+ oldChild.componentInstance._vnode!.isComment
173
+ )
171
174
  ) {
172
175
  // replace old child transition data with fresh one
173
176
  // important for dynamic transitions!
174
- const oldData: Object = oldChild.data.transition = extend({}, data)
177
+ const oldData: Object = (oldChild.data.transition = extend({}, data))
175
178
  // handle transition mode
176
179
  if (mode === 'out-in') {
177
180
  // return placeholder node and queue update when leave finishes
@@ -186,10 +189,14 @@ export default {
186
189
  return oldRawChild
187
190
  }
188
191
  let delayedLeave
189
- const performLeave = () => { delayedLeave() }
192
+ const performLeave = () => {
193
+ delayedLeave()
194
+ }
190
195
  mergeVNodeHook(data, 'afterEnter', performLeave)
191
196
  mergeVNodeHook(data, 'enterCancelled', performLeave)
192
- mergeVNodeHook(oldData, 'delayLeave', leave => { delayedLeave = leave })
197
+ mergeVNodeHook(oldData, 'delayLeave', leave => {
198
+ delayedLeave = leave
199
+ })
193
200
  }
194
201
  }
195
202
 
@@ -13,6 +13,7 @@ if (isIE9) {
13
13
  // http://www.matts411.com/post/internet-explorer-9-oninput/
14
14
  document.addEventListener('selectionchange', () => {
15
15
  const el = document.activeElement
16
+ // @ts-expect-error
16
17
  if (el && el.vmodel) {
17
18
  trigger(el, 'input')
18
19
  }
@@ -20,7 +21,7 @@ if (isIE9) {
20
21
  }
21
22
 
22
23
  const directive = {
23
- inserted (el, binding, vnode, oldVnode) {
24
+ inserted(el, binding, vnode, oldVnode) {
24
25
  if (vnode.tag === 'select') {
25
26
  // #6903
26
27
  if (oldVnode.elm && !oldVnode.elm._vOptions) {
@@ -49,7 +50,7 @@ const directive = {
49
50
  }
50
51
  },
51
52
 
52
- componentUpdated (el, binding, vnode) {
53
+ componentUpdated(el, binding, vnode) {
53
54
  if (vnode.tag === 'select') {
54
55
  setSelected(el, binding, vnode.context)
55
56
  // in case the options rendered by v-for have changed,
@@ -57,13 +58,14 @@ const directive = {
57
58
  // detect such cases and filter out values that no longer has a matching
58
59
  // option in the DOM.
59
60
  const prevOptions = el._vOptions
60
- const curOptions = el._vOptions = [].map.call(el.options, getValue)
61
+ const curOptions = (el._vOptions = [].map.call(el.options, getValue))
61
62
  if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
62
63
  // trigger change event if
63
64
  // no matching option found for at least one value
64
65
  const needReset = el.multiple
65
66
  ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
66
- : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions)
67
+ : binding.value !== binding.oldValue &&
68
+ hasNoMatchingOption(binding.value, curOptions)
67
69
  if (needReset) {
68
70
  trigger(el, 'change')
69
71
  }
@@ -72,7 +74,7 @@ const directive = {
72
74
  }
73
75
  }
74
76
 
75
- function setSelected (el, binding, vm) {
77
+ function setSelected(el, binding, vm) {
76
78
  actuallySetSelected(el, binding, vm)
77
79
  /* istanbul ignore if */
78
80
  if (isIE || isEdge) {
@@ -82,17 +84,18 @@ function setSelected (el, binding, vm) {
82
84
  }
83
85
  }
84
86
 
85
- function actuallySetSelected (el, binding, vm) {
87
+ function actuallySetSelected(el, binding, vm) {
86
88
  const value = binding.value
87
89
  const isMultiple = el.multiple
88
90
  if (isMultiple && !Array.isArray(value)) {
89
- process.env.NODE_ENV !== 'production' && warn(
90
- `<select multiple v-model="${binding.expression}"> ` +
91
- `expects an Array value for its binding, but got ${
92
- Object.prototype.toString.call(value).slice(8, -1)
93
- }`,
94
- vm
95
- )
91
+ __DEV__ &&
92
+ warn(
93
+ `<select multiple v-model="${binding.expression}"> ` +
94
+ `expects an Array value for its binding, but got ${Object.prototype.toString
95
+ .call(value)
96
+ .slice(8, -1)}`,
97
+ vm
98
+ )
96
99
  return
97
100
  }
98
101
  let selected, option
@@ -117,28 +120,26 @@ function actuallySetSelected (el, binding, vm) {
117
120
  }
118
121
  }
119
122
 
120
- function hasNoMatchingOption (value, options) {
123
+ function hasNoMatchingOption(value, options) {
121
124
  return options.every(o => !looseEqual(o, value))
122
125
  }
123
126
 
124
- function getValue (option) {
125
- return '_value' in option
126
- ? option._value
127
- : option.value
127
+ function getValue(option) {
128
+ return '_value' in option ? option._value : option.value
128
129
  }
129
130
 
130
- function onCompositionStart (e) {
131
+ function onCompositionStart(e) {
131
132
  e.target.composing = true
132
133
  }
133
134
 
134
- function onCompositionEnd (e) {
135
+ function onCompositionEnd(e) {
135
136
  // prevent triggering an input event for no reason
136
137
  if (!e.target.composing) return
137
138
  e.target.composing = false
138
139
  trigger(e.target, 'input')
139
140
  }
140
141
 
141
- function trigger (el, type) {
142
+ function trigger(el, type) {
142
143
  const e = document.createEvent('HTMLEvents')
143
144
  e.initEvent(type, true, true)
144
145
  el.dispatchEvent(e)
@@ -1,20 +1,21 @@
1
- /* @flow */
2
-
3
- import { enter, leave } from '../modules/transition'
1
+ import VNode from 'core/vdom/vnode'
2
+ import type { VNodeDirective, VNodeWithData } from 'types/vnode'
3
+ import { enter, leave } from 'web/runtime/modules/transition'
4
4
 
5
5
  // recursively search for possible transition defined inside the component root
6
- function locateNode (vnode: VNode): VNodeWithData {
6
+ function locateNode(vnode: VNode | VNodeWithData): VNodeWithData {
7
+ // @ts-expect-error
7
8
  return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
8
- ? locateNode(vnode.componentInstance._vnode)
9
+ ? locateNode(vnode.componentInstance._vnode!)
9
10
  : vnode
10
11
  }
11
12
 
12
13
  export default {
13
- bind (el: any, { value }: VNodeDirective, vnode: VNodeWithData) {
14
+ bind(el: any, { value }: VNodeDirective, vnode: VNodeWithData) {
14
15
  vnode = locateNode(vnode)
15
16
  const transition = vnode.data && vnode.data.transition
16
- const originalDisplay = el.__vOriginalDisplay =
17
- el.style.display === 'none' ? '' : el.style.display
17
+ const originalDisplay = (el.__vOriginalDisplay =
18
+ el.style.display === 'none' ? '' : el.style.display)
18
19
  if (value && transition) {
19
20
  vnode.data.show = true
20
21
  enter(vnode, () => {
@@ -25,7 +26,7 @@ export default {
25
26
  }
26
27
  },
27
28
 
28
- update (el: any, { value, oldValue }: VNodeDirective, vnode: VNodeWithData) {
29
+ update(el: any, { value, oldValue }: VNodeDirective, vnode: VNodeWithData) {
29
30
  /* istanbul ignore if */
30
31
  if (!value === !oldValue) return
31
32
  vnode = locateNode(vnode)
@@ -46,7 +47,7 @@ export default {
46
47
  }
47
48
  },
48
49
 
49
- unbind (
50
+ unbind(
50
51
  el: any,
51
52
  binding: VNodeDirective,
52
53
  vnode: VNodeWithData,
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import Vue from 'core/index'
4
2
  import config from 'core/config'
5
3
  import { extend, noop } from 'shared/util'
@@ -18,6 +16,7 @@ import {
18
16
  import { patch } from './patch'
19
17
  import platformDirectives from './directives/index'
20
18
  import platformComponents from './components/index'
19
+ import type { Component } from 'types/component'
21
20
 
22
21
  // install platform specific utils
23
22
  Vue.config.mustUseProp = mustUseProp
@@ -49,25 +48,25 @@ if (inBrowser) {
49
48
  if (config.devtools) {
50
49
  if (devtools) {
51
50
  devtools.emit('init', Vue)
52
- } else if (
53
- process.env.NODE_ENV !== 'production' &&
54
- process.env.NODE_ENV !== 'test'
55
- ) {
51
+ } else if (__DEV__ && process.env.NODE_ENV !== 'test') {
52
+ // @ts-expect-error
56
53
  console[console.info ? 'info' : 'log'](
57
54
  'Download the Vue Devtools extension for a better development experience:\n' +
58
- 'https://github.com/vuejs/vue-devtools'
55
+ 'https://github.com/vuejs/vue-devtools'
59
56
  )
60
57
  }
61
58
  }
62
- if (process.env.NODE_ENV !== 'production' &&
59
+ if (
60
+ __DEV__ &&
63
61
  process.env.NODE_ENV !== 'test' &&
64
62
  config.productionTip !== false &&
65
63
  typeof console !== 'undefined'
66
64
  ) {
65
+ // @ts-expect-error
67
66
  console[console.info ? 'info' : 'log'](
68
67
  `You are running Vue in development mode.\n` +
69
- `Make sure to turn on production mode when deploying for production.\n` +
70
- `See more tips at https://vuejs.org/guide/deployment.html`
68
+ `Make sure to turn on production mode when deploying for production.\n` +
69
+ `See more tips at https://vuejs.org/guide/deployment.html`
71
70
  )
72
71
  }
73
72
  }, 0)
@@ -1,12 +1,7 @@
1
- /* @flow */
2
-
3
1
  import { isIE, isIE9, isEdge } from 'core/util/env'
4
2
 
5
- import {
6
- extend,
7
- isDef,
8
- isUndef
9
- } from 'shared/util'
3
+ import { extend, isDef, isUndef, isTrue } from 'shared/util'
4
+ import type { VNodeWithData } from 'types/vnode'
10
5
 
11
6
  import {
12
7
  isXlink,
@@ -18,7 +13,7 @@ import {
18
13
  convertEnumeratedValue
19
14
  } from 'web/util/index'
20
15
 
21
- function updateAttrs (oldVnode: VNodeWithData, vnode: VNodeWithData) {
16
+ function updateAttrs(oldVnode: VNodeWithData, vnode: VNodeWithData) {
22
17
  const opts = vnode.componentOptions
23
18
  if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
24
19
  return
@@ -31,7 +26,7 @@ function updateAttrs (oldVnode: VNodeWithData, vnode: VNodeWithData) {
31
26
  const oldAttrs = oldVnode.data.attrs || {}
32
27
  let attrs: any = vnode.data.attrs || {}
33
28
  // clone observed objects, as the user probably wants to mutate it
34
- if (isDef(attrs.__ob__)) {
29
+ if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
35
30
  attrs = vnode.data.attrs = extend({}, attrs)
36
31
  }
37
32
 
@@ -59,7 +54,7 @@ function updateAttrs (oldVnode: VNodeWithData, vnode: VNodeWithData) {
59
54
  }
60
55
  }
61
56
 
62
- function setAttr (el: Element, key: string, value: any, isInPre: any) {
57
+ function setAttr(el: Element, key: string, value: any, isInPre?: any) {
63
58
  if (isInPre || el.tagName.indexOf('-') > -1) {
64
59
  baseSetAttr(el, key, value)
65
60
  } else if (isBooleanAttr(key)) {
@@ -70,9 +65,7 @@ function setAttr (el: Element, key: string, value: any, isInPre: any) {
70
65
  } else {
71
66
  // technically allowfullscreen is a boolean attribute for <iframe>,
72
67
  // but Flash expects a value of "true" when used on <embed> tag
73
- value = key === 'allowfullscreen' && el.tagName === 'EMBED'
74
- ? 'true'
75
- : key
68
+ value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key
76
69
  el.setAttribute(key, value)
77
70
  }
78
71
  } else if (isEnumeratedAttr(key)) {
@@ -88,7 +81,7 @@ function setAttr (el: Element, key: string, value: any, isInPre: any) {
88
81
  }
89
82
  }
90
83
 
91
- function baseSetAttr (el, key, value) {
84
+ function baseSetAttr(el, key, value) {
92
85
  if (isFalsyAttrValue(value)) {
93
86
  el.removeAttribute(key)
94
87
  } else {
@@ -97,9 +90,12 @@ function baseSetAttr (el, key, value) {
97
90
  // immediately.
98
91
  /* istanbul ignore if */
99
92
  if (
100
- isIE && !isIE9 &&
93
+ isIE &&
94
+ !isIE9 &&
101
95
  el.tagName === 'TEXTAREA' &&
102
- key === 'placeholder' && value !== '' && !el.__ieph
96
+ key === 'placeholder' &&
97
+ value !== '' &&
98
+ !el.__ieph
103
99
  ) {
104
100
  const blocker = e => {
105
101
  e.stopImmediatePropagation()