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,28 +1,17 @@
1
- /* @flow */
1
+ import { isDef, isUndef } from 'shared/util'
2
+ import type { VNodeData } from 'types/vnode'
2
3
 
3
- import {
4
- isDef,
5
- isUndef
6
- } from 'shared/util'
4
+ import { concat, stringifyClass, genClassForVnode } from 'web/util/index'
7
5
 
8
- import {
9
- concat,
10
- stringifyClass,
11
- genClassForVnode
12
- } from 'web/util/index'
13
-
14
- function updateClass (oldVnode: any, vnode: any) {
6
+ function updateClass(oldVnode: any, vnode: any) {
15
7
  const el = vnode.elm
16
8
  const data: VNodeData = vnode.data
17
9
  const oldData: VNodeData = oldVnode.data
18
10
  if (
19
11
  isUndef(data.staticClass) &&
20
- isUndef(data.class) && (
21
- isUndef(oldData) || (
22
- isUndef(oldData.staticClass) &&
23
- isUndef(oldData.class)
24
- )
25
- )
12
+ isUndef(data.class) &&
13
+ (isUndef(oldData) ||
14
+ (isUndef(oldData.staticClass) && isUndef(oldData.class)))
26
15
  ) {
27
16
  return
28
17
  }
@@ -1,11 +1,10 @@
1
- /* @flow */
2
-
3
- import { isDef, isUndef, extend, toNumber } from 'shared/util'
1
+ import { isDef, isUndef, extend, toNumber, isTrue } from 'shared/util'
2
+ import type { VNodeWithData } from 'types/vnode'
4
3
  import { isSVG } from 'web/util/index'
5
4
 
6
5
  let svgContainer
7
6
 
8
- function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
7
+ function updateDOMProps(oldVnode: VNodeWithData, vnode: VNodeWithData) {
9
8
  if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
10
9
  return
11
10
  }
@@ -14,7 +13,7 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
14
13
  const oldProps = oldVnode.data.domProps || {}
15
14
  let props = vnode.data.domProps || {}
16
15
  // clone observed objects, as the user probably wants to mutate it
17
- if (isDef(props.__ob__)) {
16
+ if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
18
17
  props = vnode.data.domProps = extend({}, props)
19
18
  }
20
19
 
@@ -48,7 +47,11 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
48
47
  if (shouldUpdateValue(elm, strCur)) {
49
48
  elm.value = strCur
50
49
  }
51
- } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
50
+ } else if (
51
+ key === 'innerHTML' &&
52
+ isSVG(elm.tagName) &&
53
+ isUndef(elm.innerHTML)
54
+ ) {
52
55
  // IE doesn't support innerHTML for SVG elements
53
56
  svgContainer = svgContainer || document.createElement('div')
54
57
  svgContainer.innerHTML = `<svg>${cur}</svg>`
@@ -70,33 +73,37 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
70
73
  // e.g. `value` on <progress> w/ non-finite value
71
74
  try {
72
75
  elm[key] = cur
73
- } catch (e) {}
76
+ } catch (e: any) {}
74
77
  }
75
78
  }
76
79
  }
77
80
 
78
81
  // check platforms/web/util/attrs.js acceptValue
79
- type acceptValueElm = HTMLInputElement | HTMLSelectElement | HTMLOptionElement;
82
+ type acceptValueElm = HTMLInputElement | HTMLSelectElement | HTMLOptionElement
80
83
 
81
- function shouldUpdateValue (elm: acceptValueElm, checkVal: string): boolean {
82
- return (!elm.composing && (
83
- elm.tagName === 'OPTION' ||
84
- isNotInFocusAndDirty(elm, checkVal) ||
85
- isDirtyWithModifiers(elm, checkVal)
86
- ))
84
+ function shouldUpdateValue(elm: acceptValueElm, checkVal: string): boolean {
85
+ return (
86
+ //@ts-expect-error
87
+ !elm.composing &&
88
+ (elm.tagName === 'OPTION' ||
89
+ isNotInFocusAndDirty(elm, checkVal) ||
90
+ isDirtyWithModifiers(elm, checkVal))
91
+ )
87
92
  }
88
93
 
89
- function isNotInFocusAndDirty (elm: acceptValueElm, checkVal: string): boolean {
94
+ function isNotInFocusAndDirty(elm: acceptValueElm, checkVal: string): boolean {
90
95
  // return true when textbox (.number and .trim) loses focus and its value is
91
96
  // not equal to the updated value
92
97
  let notInFocus = true
93
98
  // #6157
94
99
  // work around IE bug when accessing document.activeElement in an iframe
95
- try { notInFocus = document.activeElement !== elm } catch (e) {}
100
+ try {
101
+ notInFocus = document.activeElement !== elm
102
+ } catch (e: any) {}
96
103
  return notInFocus && elm.value !== checkVal
97
104
  }
98
105
 
99
- function isDirtyWithModifiers (elm: any, newVal: string): boolean {
106
+ function isDirtyWithModifiers(elm: any, newVal: string): boolean {
100
107
  const value = elm.value
101
108
  const modifiers = elm._vModifiers // injected by v-model runtime
102
109
  if (isDef(modifiers)) {
@@ -1,16 +1,19 @@
1
- /* @flow */
2
-
3
1
  import { isDef, isUndef } from 'shared/util'
4
2
  import { updateListeners } from 'core/vdom/helpers/index'
5
3
  import { isIE, isFF, supportsPassive, isUsingMicroTask } from 'core/util/index'
6
- import { RANGE_TOKEN, CHECKBOX_RADIO_TOKEN } from 'web/compiler/directives/model'
4
+ import {
5
+ RANGE_TOKEN,
6
+ CHECKBOX_RADIO_TOKEN
7
+ } from 'web/compiler/directives/model'
7
8
  import { currentFlushTimestamp } from 'core/observer/scheduler'
9
+ import { emptyNode } from 'core/vdom/patch'
10
+ import type { VNodeWithData } from 'types/vnode'
8
11
 
9
12
  // normalize v-model event tokens that can only be determined at runtime.
10
13
  // it's important to place the event as the first in the array because
11
14
  // the whole point is ensuring the v-model callback gets called before
12
15
  // user-attached handlers.
13
- function normalizeEvents (on) {
16
+ function normalizeEvents(on) {
14
17
  /* istanbul ignore if */
15
18
  if (isDef(on[RANGE_TOKEN])) {
16
19
  // IE input[type=range] only supports `change` event
@@ -29,9 +32,9 @@ function normalizeEvents (on) {
29
32
 
30
33
  let target: any
31
34
 
32
- function createOnceHandler (event, handler, capture) {
35
+ function createOnceHandler(event, handler, capture) {
33
36
  const _target = target // save current target element in closure
34
- return function onceHandler () {
37
+ return function onceHandler() {
35
38
  const res = handler.apply(null, arguments)
36
39
  if (res !== null) {
37
40
  remove(event, onceHandler, capture, _target)
@@ -44,7 +47,7 @@ function createOnceHandler (event, handler, capture) {
44
47
  // safe to exclude.
45
48
  const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53)
46
49
 
47
- function add (
50
+ function add(
48
51
  name: string,
49
52
  handler: Function,
50
53
  capture: boolean,
@@ -59,6 +62,7 @@ function add (
59
62
  if (useMicrotaskFix) {
60
63
  const attachedTimestamp = currentFlushTimestamp
61
64
  const original = handler
65
+ //@ts-expect-error
62
66
  handler = original._wrapper = function (e) {
63
67
  if (
64
68
  // no bubbling, should always fire.
@@ -83,32 +87,33 @@ function add (
83
87
  target.addEventListener(
84
88
  name,
85
89
  handler,
86
- supportsPassive
87
- ? { capture, passive }
88
- : capture
90
+ supportsPassive ? { capture, passive } : capture
89
91
  )
90
92
  }
91
93
 
92
- function remove (
94
+ function remove(
93
95
  name: string,
94
96
  handler: Function,
95
97
  capture: boolean,
96
98
  _target?: HTMLElement
97
99
  ) {
98
- (_target || target).removeEventListener(
100
+ ;(_target || target).removeEventListener(
99
101
  name,
102
+ //@ts-expect-error
100
103
  handler._wrapper || handler,
101
104
  capture
102
105
  )
103
106
  }
104
107
 
105
- function updateDOMListeners (oldVnode: VNodeWithData, vnode: VNodeWithData) {
108
+ function updateDOMListeners(oldVnode: VNodeWithData, vnode: VNodeWithData) {
106
109
  if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
107
110
  return
108
111
  }
109
112
  const on = vnode.data.on || {}
110
113
  const oldOn = oldVnode.data.on || {}
111
- target = vnode.elm
114
+ // vnode is empty when removing all listeners,
115
+ // and use old vnode dom element
116
+ target = vnode.elm || oldVnode.elm
112
117
  normalizeEvents(on)
113
118
  updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context)
114
119
  target = undefined
@@ -116,5 +121,7 @@ function updateDOMListeners (oldVnode: VNodeWithData, vnode: VNodeWithData) {
116
121
 
117
122
  export default {
118
123
  create: updateDOMListeners,
119
- update: updateDOMListeners
124
+ update: updateDOMListeners,
125
+ // @ts-expect-error emptyNode has actually data
126
+ destroy: (vnode: VNodeWithData) => updateDOMListeners(vnode, emptyNode)
120
127
  }
@@ -5,11 +5,4 @@ import domProps from './dom-props'
5
5
  import style from './style'
6
6
  import transition from './transition'
7
7
 
8
- export default [
9
- attrs,
10
- klass,
11
- events,
12
- domProps,
13
- style,
14
- transition
15
- ]
8
+ export default [attrs, klass, events, domProps, style, transition]
@@ -1,7 +1,13 @@
1
- /* @flow */
2
-
3
1
  import { getStyle, normalizeStyleBinding } from 'web/util/style'
4
- import { cached, camelize, extend, isDef, isUndef, hyphenate } from 'shared/util'
2
+ import {
3
+ cached,
4
+ camelize,
5
+ extend,
6
+ isDef,
7
+ isUndef,
8
+ hyphenate
9
+ } from 'shared/util'
10
+ import type { VNodeWithData } from 'types/vnode'
5
11
 
6
12
  const cssVarRE = /^--/
7
13
  const importantRE = /\s*!important$/
@@ -10,7 +16,11 @@ const setProp = (el, name, val) => {
10
16
  if (cssVarRE.test(name)) {
11
17
  el.style.setProperty(name, val)
12
18
  } else if (importantRE.test(val)) {
13
- el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important')
19
+ el.style.setProperty(
20
+ hyphenate(name),
21
+ val.replace(importantRE, ''),
22
+ 'important'
23
+ )
14
24
  } else {
15
25
  const normalizedName = normalize(name)
16
26
  if (Array.isArray(val)) {
@@ -18,10 +28,10 @@ const setProp = (el, name, val) => {
18
28
  // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
19
29
  // Set them one by one, and the browser will only set those it can recognize
20
30
  for (let i = 0, len = val.length; i < len; i++) {
21
- el.style[normalizedName] = val[i]
31
+ el.style[normalizedName!] = val[i]
22
32
  }
23
33
  } else {
24
- el.style[normalizedName] = val
34
+ el.style[normalizedName!] = val
25
35
  }
26
36
  }
27
37
  }
@@ -32,7 +42,7 @@ let emptyStyle
32
42
  const normalize = cached(function (prop) {
33
43
  emptyStyle = emptyStyle || document.createElement('div').style
34
44
  prop = camelize(prop)
35
- if (prop !== 'filter' && (prop in emptyStyle)) {
45
+ if (prop !== 'filter' && prop in emptyStyle) {
36
46
  return prop
37
47
  }
38
48
  const capName = prop.charAt(0).toUpperCase() + prop.slice(1)
@@ -44,12 +54,15 @@ const normalize = cached(function (prop) {
44
54
  }
45
55
  })
46
56
 
47
- function updateStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) {
57
+ function updateStyle(oldVnode: VNodeWithData, vnode: VNodeWithData) {
48
58
  const data = vnode.data
49
59
  const oldData = oldVnode.data
50
60
 
51
- if (isUndef(data.staticStyle) && isUndef(data.style) &&
52
- isUndef(oldData.staticStyle) && isUndef(oldData.style)
61
+ if (
62
+ isUndef(data.staticStyle) &&
63
+ isUndef(data.style) &&
64
+ isUndef(oldData.staticStyle) &&
65
+ isUndef(oldData.style)
53
66
  ) {
54
67
  return
55
68
  }
@@ -67,9 +80,7 @@ function updateStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) {
67
80
  // store normalized style under a different key for next diff
68
81
  // make sure to clone it if it's reactive, since the user likely wants
69
82
  // to mutate it.
70
- vnode.data.normalizedStyle = isDef(style.__ob__)
71
- ? extend({}, style)
72
- : style
83
+ vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style
73
84
 
74
85
  const newStyle = getStyle(vnode, true)
75
86
 
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import { inBrowser, isIE9, warn } from 'core/util/index'
4
2
  import { mergeVNodeHook } from 'core/vdom/helpers/index'
5
3
  import { activeInstance } from 'core/instance/lifecycle'
@@ -9,7 +7,8 @@ import {
9
7
  isDef,
10
8
  isUndef,
11
9
  isObject,
12
- toNumber
10
+ toNumber,
11
+ isFunction
13
12
  } from 'shared/util'
14
13
 
15
14
  import {
@@ -18,9 +17,12 @@ import {
18
17
  whenTransitionEnds,
19
18
  addTransitionClass,
20
19
  removeTransitionClass
21
- } from '../transition-util'
20
+ } from 'web/runtime/transition-util'
21
+
22
+ import type { VNodeWithData } from 'types/vnode'
23
+ import VNode from 'core/vdom/vnode'
22
24
 
23
- export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
25
+ export function enter(vnode: VNodeWithData, toggleDisplay?: () => void) {
24
26
  const el: any = vnode.elm
25
27
 
26
28
  // call leave callback now
@@ -76,47 +78,35 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
76
78
  return
77
79
  }
78
80
 
79
- const startClass = isAppear && appearClass
80
- ? appearClass
81
- : enterClass
82
- const activeClass = isAppear && appearActiveClass
83
- ? appearActiveClass
84
- : enterActiveClass
85
- const toClass = isAppear && appearToClass
86
- ? appearToClass
87
- : enterToClass
88
-
89
- const beforeEnterHook = isAppear
90
- ? (beforeAppear || beforeEnter)
91
- : beforeEnter
92
- const enterHook = isAppear
93
- ? (typeof appear === 'function' ? appear : enter)
94
- : enter
95
- const afterEnterHook = isAppear
96
- ? (afterAppear || afterEnter)
97
- : afterEnter
81
+ const startClass = isAppear && appearClass ? appearClass : enterClass
82
+ const activeClass =
83
+ isAppear && appearActiveClass ? appearActiveClass : enterActiveClass
84
+ const toClass = isAppear && appearToClass ? appearToClass : enterToClass
85
+
86
+ const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter
87
+ const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter
88
+ const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter
98
89
  const enterCancelledHook = isAppear
99
- ? (appearCancelled || enterCancelled)
90
+ ? appearCancelled || enterCancelled
100
91
  : enterCancelled
101
92
 
102
93
  const explicitEnterDuration: any = toNumber(
103
- isObject(duration)
104
- ? duration.enter
105
- : duration
94
+ isObject(duration) ? duration.enter : duration
106
95
  )
107
96
 
108
- if (process.env.NODE_ENV !== 'production' && explicitEnterDuration != null) {
97
+ if (__DEV__ && explicitEnterDuration != null) {
109
98
  checkDuration(explicitEnterDuration, 'enter', vnode)
110
99
  }
111
100
 
112
101
  const expectsCSS = css !== false && !isIE9
113
102
  const userWantsControl = getHookArgumentsLength(enterHook)
114
103
 
115
- const cb = el._enterCb = once(() => {
104
+ const cb = (el._enterCb = once(() => {
116
105
  if (expectsCSS) {
117
106
  removeTransitionClass(el, toClass)
118
107
  removeTransitionClass(el, activeClass)
119
108
  }
109
+ // @ts-expect-error
120
110
  if (cb.cancelled) {
121
111
  if (expectsCSS) {
122
112
  removeTransitionClass(el, startClass)
@@ -126,14 +116,16 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
126
116
  afterEnterHook && afterEnterHook(el)
127
117
  }
128
118
  el._enterCb = null
129
- })
119
+ }))
130
120
 
131
121
  if (!vnode.data.show) {
132
122
  // remove pending leave element on enter by injecting an insert hook
133
123
  mergeVNodeHook(vnode, 'insert', () => {
134
124
  const parent = el.parentNode
135
- const pendingNode = parent && parent._pending && parent._pending[vnode.key]
136
- if (pendingNode &&
125
+ const pendingNode =
126
+ parent && parent._pending && parent._pending[vnode.key!]
127
+ if (
128
+ pendingNode &&
137
129
  pendingNode.tag === vnode.tag &&
138
130
  pendingNode.elm._leaveCb
139
131
  ) {
@@ -150,6 +142,7 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
150
142
  addTransitionClass(el, activeClass)
151
143
  nextFrame(() => {
152
144
  removeTransitionClass(el, startClass)
145
+ // @ts-expect-error
153
146
  if (!cb.cancelled) {
154
147
  addTransitionClass(el, toClass)
155
148
  if (!userWantsControl) {
@@ -173,7 +166,7 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
173
166
  }
174
167
  }
175
168
 
176
- export function leave (vnode: VNodeWithData, rm: Function) {
169
+ export function leave(vnode: VNodeWithData, rm: Function) {
177
170
  const el: any = vnode.elm
178
171
 
179
172
  // call enter callback now
@@ -210,23 +203,22 @@ export function leave (vnode: VNodeWithData, rm: Function) {
210
203
  const userWantsControl = getHookArgumentsLength(leave)
211
204
 
212
205
  const explicitLeaveDuration: any = toNumber(
213
- isObject(duration)
214
- ? duration.leave
215
- : duration
206
+ isObject(duration) ? duration.leave : duration
216
207
  )
217
208
 
218
- if (process.env.NODE_ENV !== 'production' && isDef(explicitLeaveDuration)) {
209
+ if (__DEV__ && isDef(explicitLeaveDuration)) {
219
210
  checkDuration(explicitLeaveDuration, 'leave', vnode)
220
211
  }
221
212
 
222
- const cb = el._leaveCb = once(() => {
213
+ const cb = (el._leaveCb = once(() => {
223
214
  if (el.parentNode && el.parentNode._pending) {
224
- el.parentNode._pending[vnode.key] = null
215
+ el.parentNode._pending[vnode.key!] = null
225
216
  }
226
217
  if (expectsCSS) {
227
218
  removeTransitionClass(el, leaveToClass)
228
219
  removeTransitionClass(el, leaveActiveClass)
229
220
  }
221
+ // @ts-expect-error
230
222
  if (cb.cancelled) {
231
223
  if (expectsCSS) {
232
224
  removeTransitionClass(el, leaveClass)
@@ -237,7 +229,7 @@ export function leave (vnode: VNodeWithData, rm: Function) {
237
229
  afterLeave && afterLeave(el)
238
230
  }
239
231
  el._leaveCb = null
240
- })
232
+ }))
241
233
 
242
234
  if (delayLeave) {
243
235
  delayLeave(performLeave)
@@ -245,14 +237,16 @@ export function leave (vnode: VNodeWithData, rm: Function) {
245
237
  performLeave()
246
238
  }
247
239
 
248
- function performLeave () {
240
+ function performLeave() {
249
241
  // the delayed leave may have already been cancelled
242
+ // @ts-expect-error
250
243
  if (cb.cancelled) {
251
244
  return
252
245
  }
253
246
  // record leaving element
254
247
  if (!vnode.data.show && el.parentNode) {
255
- (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key: any)] = vnode
248
+ ;(el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key!] =
249
+ vnode
256
250
  }
257
251
  beforeLeave && beforeLeave(el)
258
252
  if (expectsCSS) {
@@ -260,6 +254,7 @@ export function leave (vnode: VNodeWithData, rm: Function) {
260
254
  addTransitionClass(el, leaveActiveClass)
261
255
  nextFrame(() => {
262
256
  removeTransitionClass(el, leaveClass)
257
+ // @ts-expect-error
263
258
  if (!cb.cancelled) {
264
259
  addTransitionClass(el, leaveToClass)
265
260
  if (!userWantsControl) {
@@ -280,23 +275,23 @@ export function leave (vnode: VNodeWithData, rm: Function) {
280
275
  }
281
276
 
282
277
  // only used in dev mode
283
- function checkDuration (val, name, vnode) {
278
+ function checkDuration(val, name, vnode) {
284
279
  if (typeof val !== 'number') {
285
280
  warn(
286
281
  `<transition> explicit ${name} duration is not a valid number - ` +
287
- `got ${JSON.stringify(val)}.`,
282
+ `got ${JSON.stringify(val)}.`,
288
283
  vnode.context
289
284
  )
290
285
  } else if (isNaN(val)) {
291
286
  warn(
292
287
  `<transition> explicit ${name} duration is NaN - ` +
293
- 'the duration expression might be incorrect.',
288
+ 'the duration expression might be incorrect.',
294
289
  vnode.context
295
290
  )
296
291
  }
297
292
  }
298
293
 
299
- function isValidDuration (val) {
294
+ function isValidDuration(val) {
300
295
  return typeof val === 'number' && !isNaN(val)
301
296
  }
302
297
 
@@ -306,38 +301,41 @@ function isValidDuration (val) {
306
301
  * - a wrapped component method (check ._length)
307
302
  * - a plain function (.length)
308
303
  */
309
- function getHookArgumentsLength (fn: Function): boolean {
304
+ function getHookArgumentsLength(fn: Function): boolean {
310
305
  if (isUndef(fn)) {
311
306
  return false
312
307
  }
308
+ // @ts-expect-error
313
309
  const invokerFns = fn.fns
314
310
  if (isDef(invokerFns)) {
315
311
  // invoker
316
312
  return getHookArgumentsLength(
317
- Array.isArray(invokerFns)
318
- ? invokerFns[0]
319
- : invokerFns
313
+ Array.isArray(invokerFns) ? invokerFns[0] : invokerFns
320
314
  )
321
315
  } else {
316
+ // @ts-expect-error
322
317
  return (fn._length || fn.length) > 1
323
318
  }
324
319
  }
325
320
 
326
- function _enter (_: any, vnode: VNodeWithData) {
321
+ function _enter(_: any, vnode: VNodeWithData) {
327
322
  if (vnode.data.show !== true) {
328
323
  enter(vnode)
329
324
  }
330
325
  }
331
326
 
332
- export default inBrowser ? {
333
- create: _enter,
334
- activate: _enter,
335
- remove (vnode: VNode, rm: Function) {
336
- /* istanbul ignore else */
337
- if (vnode.data.show !== true) {
338
- leave(vnode, rm)
339
- } else {
340
- rm()
327
+ export default inBrowser
328
+ ? {
329
+ create: _enter,
330
+ activate: _enter,
331
+ remove(vnode: VNode, rm: Function) {
332
+ /* istanbul ignore else */
333
+ if (vnode.data!.show !== true) {
334
+ // @ts-expect-error
335
+ leave(vnode, rm)
336
+ } else {
337
+ rm()
338
+ }
339
+ }
341
340
  }
342
- }
343
- } : {}
341
+ : {}
@@ -0,0 +1,66 @@
1
+ import VNode from 'core/vdom/vnode'
2
+ import { namespaceMap } from 'web/util/index'
3
+
4
+ export function createElement(tagName: string, vnode: VNode): Element {
5
+ const elm = document.createElement(tagName)
6
+ if (tagName !== 'select') {
7
+ return elm
8
+ }
9
+ // false or null will remove the attribute but undefined will not
10
+ if (
11
+ vnode.data &&
12
+ vnode.data.attrs &&
13
+ vnode.data.attrs.multiple !== undefined
14
+ ) {
15
+ elm.setAttribute('multiple', 'multiple')
16
+ }
17
+ return elm
18
+ }
19
+
20
+ export function createElementNS(namespace: string, tagName: string): Element {
21
+ return document.createElementNS(namespaceMap[namespace], tagName)
22
+ }
23
+
24
+ export function createTextNode(text: string): Text {
25
+ return document.createTextNode(text)
26
+ }
27
+
28
+ export function createComment(text: string): Comment {
29
+ return document.createComment(text)
30
+ }
31
+
32
+ export function insertBefore(
33
+ parentNode: Node,
34
+ newNode: Node,
35
+ referenceNode: Node
36
+ ) {
37
+ parentNode.insertBefore(newNode, referenceNode)
38
+ }
39
+
40
+ export function removeChild(node: Node, child: Node) {
41
+ node.removeChild(child)
42
+ }
43
+
44
+ export function appendChild(node: Node, child: Node) {
45
+ node.appendChild(child)
46
+ }
47
+
48
+ export function parentNode(node: Node) {
49
+ return node.parentNode
50
+ }
51
+
52
+ export function nextSibling(node: Node) {
53
+ return node.nextSibling
54
+ }
55
+
56
+ export function tagName(node: Element): string {
57
+ return node.tagName
58
+ }
59
+
60
+ export function setTextContent(node: Node, text: string) {
61
+ node.textContent = text
62
+ }
63
+
64
+ export function setStyleScope(node: Element, scopeId: string) {
65
+ node.setAttribute(scopeId, '')
66
+ }
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import * as nodeOps from 'web/runtime/node-ops'
4
2
  import { createPatchFunction } from 'core/vdom/patch'
5
3
  import baseModules from 'core/vdom/modules/index'