vue 2.7.12 → 2.7.14
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.
- package/dist/vue.common.dev.js +102 -85
- package/dist/vue.common.prod.js +3 -3
- package/dist/vue.esm.browser.js +102 -85
- package/dist/vue.esm.browser.min.js +3 -3
- package/dist/vue.esm.js +103 -85
- package/dist/vue.js +103 -85
- package/dist/vue.min.js +3 -3
- package/dist/vue.runtime.common.dev.js +101 -84
- package/dist/vue.runtime.common.prod.js +3 -3
- package/dist/vue.runtime.esm.js +102 -84
- package/dist/vue.runtime.js +102 -84
- package/dist/vue.runtime.min.js +3 -3
- package/package.json +2 -2
- package/packages/compiler-sfc/dist/compiler-sfc.js +26 -13
- package/packages/compiler-sfc/package.json +1 -1
- package/packages/compiler-sfc/src/compileScript.ts +3 -1
- package/packages/compiler-sfc/test/compileScript.spec.ts +17 -1
- package/src/compiler/codegen/index.ts +1 -1
- package/src/compiler/parser/index.ts +1 -1
- package/src/core/observer/index.ts +0 -2
- package/src/core/observer/traverse.ts +1 -0
- package/src/core/util/options.ts +19 -3
- package/src/v3/reactivity/effectScope.ts +4 -5
- package/src/v3/reactivity/reactive.ts +4 -6
- package/src/v3/reactivity/readonly.ts +11 -5
- package/types/jsx.d.ts +4 -2
- package/types/v3-generated.d.ts +1 -0
- package/types/vnode.d.ts +2 -1
package/src/core/util/options.ts
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
@@ -16,9 +16,7 @@ export class EffectScope {
|
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
18
|
cleanups: (() => void)[] = []
|
|
19
|
-
|
|
20
19
|
/**
|
|
21
|
-
* only assigned by undetached scope
|
|
22
20
|
* @internal
|
|
23
21
|
*/
|
|
24
22
|
parent: EffectScope | undefined
|
|
@@ -38,9 +36,9 @@ export class EffectScope {
|
|
|
38
36
|
*/
|
|
39
37
|
private index: number | undefined
|
|
40
38
|
|
|
41
|
-
constructor(detached = false) {
|
|
39
|
+
constructor(public detached = false) {
|
|
40
|
+
this.parent = activeEffectScope
|
|
42
41
|
if (!detached && activeEffectScope) {
|
|
43
|
-
this.parent = activeEffectScope
|
|
44
42
|
this.index =
|
|
45
43
|
(activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
|
|
46
44
|
this
|
|
@@ -93,7 +91,7 @@ export class EffectScope {
|
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
// nested scope, dereference from parent to avoid memory leaks
|
|
96
|
-
if (this.parent && !fromParent) {
|
|
94
|
+
if (!this.detached && this.parent && !fromParent) {
|
|
97
95
|
// optimized O(1) removal
|
|
98
96
|
const last = this.parent.scopes!.pop()
|
|
99
97
|
if (last && last !== this) {
|
|
@@ -101,6 +99,7 @@ export class EffectScope {
|
|
|
101
99
|
last.index = this.index!
|
|
102
100
|
}
|
|
103
101
|
}
|
|
102
|
+
this.parent = undefined
|
|
104
103
|
this.active = false
|
|
105
104
|
}
|
|
106
105
|
}
|
|
@@ -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
|
-
|
|
126
|
-
|
|
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
|
|
36
|
-
const
|
|
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
|
|
67
|
-
const existingProxy =
|
|
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
|
-
|
|
79
|
+
def(target, existingFlag, proxy)
|
|
74
80
|
|
|
75
81
|
def(proxy, ReactiveFlags.IS_READONLY, true)
|
|
76
82
|
def(proxy, ReactiveFlags.RAW, target)
|
package/types/jsx.d.ts
CHANGED
|
@@ -731,7 +731,7 @@ export interface SVGAttributes extends AriaAttributes, EventHandlers<Events> {
|
|
|
731
731
|
* @see https://www.w3.org/TR/SVG/styling.html#ElementSpecificStyling
|
|
732
732
|
*/
|
|
733
733
|
class?: any
|
|
734
|
-
style?:
|
|
734
|
+
style?: StyleValue
|
|
735
735
|
|
|
736
736
|
color?: string
|
|
737
737
|
height?: Numberish
|
|
@@ -1297,7 +1297,9 @@ export interface Events {
|
|
|
1297
1297
|
}
|
|
1298
1298
|
|
|
1299
1299
|
type EventHandlers<E> = {
|
|
1300
|
-
[K in keyof E]?: E[K] extends
|
|
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 = {
|
package/types/v3-generated.d.ts
CHANGED
|
@@ -91,6 +91,7 @@ export declare function del(object: object, key: string | number): void;
|
|
|
91
91
|
/* Excluded from this release type: DepTarget */
|
|
92
92
|
|
|
93
93
|
export declare class EffectScope {
|
|
94
|
+
detached: boolean;
|
|
94
95
|
/* Excluded from this release type: active */
|
|
95
96
|
/* Excluded from this release type: effects */
|
|
96
97
|
/* Excluded from this release type: cleanups */
|
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?:
|
|
89
|
+
style?: StyleValue
|
|
89
90
|
props?: { [key: string]: any }
|
|
90
91
|
attrs?: { [key: string]: any }
|
|
91
92
|
domProps?: { [key: string]: any }
|