vue 2.7.13 → 2.7.15

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 (42) hide show
  1. package/dist/vue.common.dev.js +219 -200
  2. package/dist/vue.common.prod.js +5 -5
  3. package/dist/vue.esm.browser.js +219 -200
  4. package/dist/vue.esm.browser.min.js +5 -5
  5. package/dist/vue.esm.js +223 -203
  6. package/dist/vue.js +223 -203
  7. package/dist/vue.min.js +5 -5
  8. package/dist/vue.runtime.common.dev.js +113 -92
  9. package/dist/vue.runtime.common.prod.js +5 -5
  10. package/dist/vue.runtime.esm.js +114 -92
  11. package/dist/vue.runtime.js +114 -92
  12. package/dist/vue.runtime.min.js +5 -5
  13. package/package.json +7 -7
  14. package/packages/compiler-sfc/dist/compiler-sfc.js +43 -28
  15. package/packages/compiler-sfc/node_modules/.bin/lessc +4 -4
  16. package/packages/compiler-sfc/node_modules/.bin/parser +4 -4
  17. package/packages/compiler-sfc/node_modules/.bin/sass +4 -4
  18. package/packages/compiler-sfc/node_modules/.bin/stylus +4 -4
  19. package/packages/compiler-sfc/package.json +1 -1
  20. package/packages/compiler-sfc/src/compileScript.ts +13 -8
  21. package/packages/compiler-sfc/test/__snapshots__/compileScript.spec.ts.snap +41 -9
  22. package/packages/compiler-sfc/test/__snapshots__/cssVars.spec.ts.snap +1 -1
  23. package/packages/compiler-sfc/test/compileScript.spec.ts +45 -1
  24. package/src/compiler/codegen/index.ts +1 -1
  25. package/src/compiler/parser/html-parser.ts +1 -1
  26. package/src/compiler/parser/index.ts +1 -1
  27. package/src/core/instance/lifecycle.ts +8 -2
  28. package/src/core/observer/index.ts +3 -5
  29. package/src/core/util/options.ts +19 -3
  30. package/src/core/vdom/patch.ts +5 -2
  31. package/src/platforms/web/util/element.ts +1 -1
  32. package/src/shared/util.ts +1 -3
  33. package/src/types/utils.ts +1 -1
  34. package/src/v3/apiAsyncComponent.ts +1 -1
  35. package/src/v3/reactivity/reactive.ts +4 -6
  36. package/src/v3/reactivity/readonly.ts +11 -5
  37. package/types/common.d.ts +1 -1
  38. package/types/jsx.d.ts +3 -1
  39. package/types/options.d.ts +1 -1
  40. package/types/v3-setup-helpers.d.ts +5 -1
  41. package/types/vnode.d.ts +2 -1
  42. package/dist/compiler-sfc.js +0 -14
@@ -51,7 +51,8 @@ if (__DEV__) {
51
51
  */
52
52
  function mergeData(
53
53
  to: Record<string | symbol, any>,
54
- from: Record<string | symbol, any> | null
54
+ from: Record<string | symbol, any> | null,
55
+ recursive = true
55
56
  ): Record<PropertyKey, any> {
56
57
  if (!from) return to
57
58
  let key, toVal, fromVal
@@ -66,7 +67,7 @@ function mergeData(
66
67
  if (key === '__ob__') continue
67
68
  toVal = to[key]
68
69
  fromVal = from[key]
69
- if (!hasOwn(to, key)) {
70
+ if (!recursive || !hasOwn(to, key)) {
70
71
  set(to, key, fromVal)
71
72
  } else if (
72
73
  toVal !== fromVal &&
@@ -262,7 +263,22 @@ strats.props =
262
263
  if (childVal) extend(ret, childVal)
263
264
  return ret
264
265
  }
265
- strats.provide = mergeDataOrFn
266
+
267
+ strats.provide = function (parentVal: Object | null, childVal: Object | null) {
268
+ if (!parentVal) return childVal
269
+ return function () {
270
+ const ret = Object.create(null)
271
+ mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal)
272
+ if (childVal) {
273
+ mergeData(
274
+ ret,
275
+ isFunction(childVal) ? childVal.call(this) : childVal,
276
+ false // non-recursive
277
+ )
278
+ }
279
+ return ret
280
+ }
281
+ }
266
282
 
267
283
  /**
268
284
  * Default strategy.
@@ -878,8 +878,11 @@ export function createPatchFunction(backend) {
878
878
  const insert = ancestor.data.hook.insert
879
879
  if (insert.merged) {
880
880
  // start at index 1 to avoid re-invoking component mounted hook
881
- for (let i = 1; i < insert.fns.length; i++) {
882
- insert.fns[i]()
881
+ // clone insert hooks to avoid being mutated during iteration.
882
+ // e.g. for customed directives under transition group.
883
+ const cloned = insert.fns.slice(1)
884
+ for (let i = 0; i < cloned.length; i++) {
885
+ cloned[i]()
883
886
  }
884
887
  }
885
888
  } else {
@@ -62,7 +62,7 @@ export function isUnknownElement(tag: string): boolean {
62
62
  }
63
63
  const el = document.createElement(tag)
64
64
  if (tag.indexOf('-') > -1) {
65
- // http://stackoverflow.com/a/28210364/1070244
65
+ // https://stackoverflow.com/a/28210364/1070244
66
66
  return (unknownElementCache[tag] =
67
67
  el.constructor === window.HTMLUnknownElement ||
68
68
  el.constructor === window.HTMLElement)
@@ -286,9 +286,7 @@ export function genStaticKeys(
286
286
  modules: Array<{ staticKeys?: string[] } /* ModuleOptions */>
287
287
  ): string {
288
288
  return modules
289
- .reduce((keys, m) => {
290
- return keys.concat(m.staticKeys || [])
291
- }, [] as string[])
289
+ .reduce<string[]>((keys, m) => keys.concat(m.staticKeys || []), [])
292
290
  .join(',')
293
291
  }
294
292
 
@@ -1,3 +1,3 @@
1
- // If the the type T accepts type "any", output type Y, otherwise output type N.
1
+ // If the type T accepts type "any", output type Y, otherwise output type N.
2
2
  // https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
3
3
  export type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N
@@ -47,7 +47,7 @@ export function defineAsyncComponent(
47
47
 
48
48
  if (__DEV__ && suspensible) {
49
49
  warn(
50
- `The suspensiblbe option for async components is not supported in Vue2. It is ignored.`
50
+ `The suspensible option for async components is not supported in Vue2. It is ignored.`
51
51
  )
52
52
  }
53
53
 
@@ -5,13 +5,10 @@ import {
5
5
  isPrimitive,
6
6
  warn,
7
7
  toRawType,
8
- isServerRendering,
9
- isObject
8
+ isServerRendering
10
9
  } from 'core/util'
11
10
  import type { Ref, UnwrapRefSimple, RawSymbol } from './ref'
12
11
 
13
- export const rawMap = new WeakMap()
14
-
15
12
  export const enum ReactiveFlags {
16
13
  SKIP = '__v_skip',
17
14
  IS_READONLY = '__v_isReadonly',
@@ -122,8 +119,9 @@ export function toRaw<T>(observed: T): T {
122
119
  export function markRaw<T extends object>(
123
120
  value: T
124
121
  ): T & { [RawSymbol]?: true } {
125
- if (isObject(value)) {
126
- rawMap.set(value, true)
122
+ // non-extensible objects won't be observed anyway
123
+ if (Object.isExtensible(value)) {
124
+ def(value, ReactiveFlags.SKIP, true)
127
125
  }
128
126
  return value
129
127
  }
@@ -32,8 +32,8 @@ export type DeepReadonly<T> = T extends Builtin
32
32
  ? { readonly [K in keyof T]: DeepReadonly<T[K]> }
33
33
  : Readonly<T>
34
34
 
35
- const rawToReadonlyMap = new WeakMap()
36
- const rawToShallowReadonlyMap = new WeakMap()
35
+ const rawToReadonlyFlag = `__v_rawToReadonly`
36
+ const rawToShallowReadonlyFlag = `__v_rawToShallowReadonly`
37
37
 
38
38
  export function readonly<T extends object>(
39
39
  target: T
@@ -57,20 +57,26 @@ function createReadonly(target: any, shallow: boolean) {
57
57
  return target as any
58
58
  }
59
59
 
60
+ if (__DEV__ && !Object.isExtensible(target)) {
61
+ warn(
62
+ `Vue 2 does not support creating readonly proxy for non-extensible object.`
63
+ )
64
+ }
65
+
60
66
  // already a readonly object
61
67
  if (isReadonly(target)) {
62
68
  return target as any
63
69
  }
64
70
 
65
71
  // already has a readonly proxy
66
- const map = shallow ? rawToShallowReadonlyMap : rawToReadonlyMap
67
- const existingProxy = map.get(target)
72
+ const existingFlag = shallow ? rawToShallowReadonlyFlag : rawToReadonlyFlag
73
+ const existingProxy = target[existingFlag]
68
74
  if (existingProxy) {
69
75
  return existingProxy
70
76
  }
71
77
 
72
78
  const proxy = Object.create(Object.getPrototypeOf(target))
73
- map.set(target, proxy)
79
+ def(target, existingFlag, proxy)
74
80
 
75
81
  def(proxy, ReactiveFlags.IS_READONLY, true)
76
82
  def(proxy, ReactiveFlags.RAW, target)
package/types/common.d.ts CHANGED
@@ -14,7 +14,7 @@ type Equal<Left, Right> =
14
14
 
15
15
  export type HasDefined<T> = Equal<T, unknown> extends true ? false : true
16
16
 
17
- // If the the type T accepts type "any", output type Y, otherwise output type N.
17
+ // If the type T accepts type "any", output type Y, otherwise output type N.
18
18
  // https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
19
19
  export type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N
20
20
 
package/types/jsx.d.ts CHANGED
@@ -1297,7 +1297,9 @@ export interface Events {
1297
1297
  }
1298
1298
 
1299
1299
  type EventHandlers<E> = {
1300
- [K in keyof E]?: E[K] extends Function ? E[K] : (payload: E[K]) => void
1300
+ [K in keyof E]?: E[K] extends (...args: any) => any
1301
+ ? E[K]
1302
+ : (payload: E[K]) => void
1301
1303
  }
1302
1304
 
1303
1305
  type ReservedProps = {
@@ -210,7 +210,7 @@ export interface ComponentOptions<
210
210
  activated?(): void
211
211
  deactivated?(): void
212
212
  errorCaptured?(err: Error, vm: Vue, info: string): boolean | void
213
- serverPrefetch?(this: V): Promise<void>
213
+ serverPrefetch?(): Promise<void>
214
214
  renderTracked?(e: DebuggerEvent): void
215
215
  renderTriggerd?(e: DebuggerEvent): void
216
216
 
@@ -110,7 +110,11 @@ type InferDefault<P, T> = T extends
110
110
  : (props: P) => T
111
111
 
112
112
  type PropsWithDefaults<Base, Defaults> = Base & {
113
- [K in keyof Defaults]: K extends keyof Base ? NotUndefined<Base[K]> : never
113
+ [K in keyof Defaults]: K extends keyof Base
114
+ ? Defaults[K] extends undefined
115
+ ? Base[K]
116
+ : NotUndefined<Base[K]>
117
+ : never
114
118
  }
115
119
 
116
120
  /**
package/types/vnode.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { StyleValue } from './jsx'
1
2
  import { Vue } from './vue'
2
3
  import { DirectiveFunction, DirectiveOptions } from './options'
3
4
  import { Ref } from './v3-generated'
@@ -85,7 +86,7 @@ export interface VNodeData {
85
86
  staticClass?: string
86
87
  class?: any
87
88
  staticStyle?: { [key: string]: any }
88
- style?: string | object[] | object
89
+ style?: StyleValue
89
90
  props?: { [key: string]: any }
90
91
  attrs?: { [key: string]: any }
91
92
  domProps?: { [key: string]: any }
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var compilerSfc = require('@vue/compiler-sfc');
6
-
7
-
8
-
9
- Object.keys(compilerSfc).forEach(function (k) {
10
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
11
- enumerable: true,
12
- get: function () { return compilerSfc[k]; }
13
- });
14
- });