vue 2.7.4 → 2.7.5
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 +3631 -3616
- package/dist/vue.common.prod.js +3 -3
- package/dist/vue.esm.browser.js +3569 -3554
- package/dist/vue.esm.browser.min.js +3 -3
- package/dist/vue.esm.js +3807 -3791
- package/dist/vue.js +3775 -3759
- package/dist/vue.min.js +3 -3
- package/dist/vue.runtime.common.dev.js +2773 -2758
- package/dist/vue.runtime.common.prod.js +3 -3
- package/dist/vue.runtime.esm.js +2922 -2906
- package/dist/vue.runtime.js +3113 -3097
- package/dist/vue.runtime.min.js +3 -3
- package/dist/vue.runtime.mjs +1 -0
- package/package.json +2 -2
- package/packages/compiler-sfc/dist/compiler-sfc.js +1030 -1024
- package/packages/compiler-sfc/package.json +1 -1
- package/src/core/components/keep-alive.ts +5 -4
- package/src/core/global-api/extend.ts +3 -1
- package/src/core/instance/init.ts +1 -1
- package/src/core/instance/lifecycle.ts +8 -3
- package/src/core/observer/traverse.ts +3 -0
- package/src/core/util/debug.ts +2 -1
- package/src/core/vdom/create-component.ts +5 -1
- package/src/platforms/web/runtime/components/transition-group.ts +2 -1
- package/src/v3/apiWatch.ts +4 -6
- package/src/v3/reactivity/ref.ts +11 -2
- package/types/options.d.ts +2 -0
- package/types/v3-component-public-instance.d.ts +15 -15
- package/types/vue.d.ts +17 -9
|
@@ -3,6 +3,7 @@ import { getFirstComponentChild } from 'core/vdom/helpers/index'
|
|
|
3
3
|
import type VNode from 'core/vdom/vnode'
|
|
4
4
|
import type { VNodeComponentOptions } from 'types/vnode'
|
|
5
5
|
import type { Component } from 'types/component'
|
|
6
|
+
import { getComponentName } from '../vdom/create-component'
|
|
6
7
|
|
|
7
8
|
type CacheEntry = {
|
|
8
9
|
name?: string
|
|
@@ -12,8 +13,8 @@ type CacheEntry = {
|
|
|
12
13
|
|
|
13
14
|
type CacheEntryMap = Record<string, CacheEntry | null>
|
|
14
15
|
|
|
15
|
-
function
|
|
16
|
-
return opts && (opts.Ctor.options
|
|
16
|
+
function _getComponentName(opts?: VNodeComponentOptions): string | null {
|
|
17
|
+
return opts && (getComponentName(opts.Ctor.options as any) || opts.tag)
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
function matches(
|
|
@@ -81,7 +82,7 @@ export default {
|
|
|
81
82
|
if (vnodeToCache) {
|
|
82
83
|
const { tag, componentInstance, componentOptions } = vnodeToCache
|
|
83
84
|
cache[keyToCache] = {
|
|
84
|
-
name:
|
|
85
|
+
name: _getComponentName(componentOptions),
|
|
85
86
|
tag,
|
|
86
87
|
componentInstance
|
|
87
88
|
}
|
|
@@ -126,7 +127,7 @@ export default {
|
|
|
126
127
|
const componentOptions = vnode && vnode.componentOptions
|
|
127
128
|
if (componentOptions) {
|
|
128
129
|
// check pattern
|
|
129
|
-
const name =
|
|
130
|
+
const name = _getComponentName(componentOptions)
|
|
130
131
|
const { include, exclude } = this
|
|
131
132
|
if (
|
|
132
133
|
// not included
|
|
@@ -3,6 +3,7 @@ import type { Component } from 'types/component'
|
|
|
3
3
|
import type { GlobalAPI } from 'types/global-api'
|
|
4
4
|
import { defineComputed, proxy } from '../instance/state'
|
|
5
5
|
import { extend, mergeOptions, validateComponentName } from '../util/index'
|
|
6
|
+
import { getComponentName } from '../vdom/create-component'
|
|
6
7
|
|
|
7
8
|
export function initExtend(Vue: GlobalAPI) {
|
|
8
9
|
/**
|
|
@@ -25,7 +26,8 @@ export function initExtend(Vue: GlobalAPI) {
|
|
|
25
26
|
return cachedCtors[SuperId]
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
const name =
|
|
29
|
+
const name =
|
|
30
|
+
getComponentName(extendOptions) || getComponentName(Super.options)
|
|
29
31
|
if (__DEV__ && name) {
|
|
30
32
|
validateComponentName(name)
|
|
31
33
|
}
|
|
@@ -58,7 +58,7 @@ export function initMixin(Vue: typeof Component) {
|
|
|
58
58
|
initLifecycle(vm)
|
|
59
59
|
initEvents(vm)
|
|
60
60
|
initRender(vm)
|
|
61
|
-
callHook(vm, 'beforeCreate')
|
|
61
|
+
callHook(vm, 'beforeCreate', undefined, false /* setContext */)
|
|
62
62
|
initInjections(vm) // resolve injections before data/props
|
|
63
63
|
initState(vm)
|
|
64
64
|
initProvide(vm) // resolve provide after data/props
|
|
@@ -375,11 +375,16 @@ export function deactivateChildComponent(vm: Component, direct?: boolean) {
|
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
export function callHook(
|
|
378
|
+
export function callHook(
|
|
379
|
+
vm: Component,
|
|
380
|
+
hook: string,
|
|
381
|
+
args?: any[],
|
|
382
|
+
setContext = true
|
|
383
|
+
) {
|
|
379
384
|
// #7573 disable dep collection when invoking lifecycle hooks
|
|
380
385
|
pushTarget()
|
|
381
386
|
const prev = currentInstance
|
|
382
|
-
setCurrentInstance(vm)
|
|
387
|
+
setContext && setCurrentInstance(vm)
|
|
383
388
|
const handlers = vm.$options[hook]
|
|
384
389
|
const info = `${hook} hook`
|
|
385
390
|
if (handlers) {
|
|
@@ -390,6 +395,6 @@ export function callHook(vm: Component, hook: string, args?: any[]) {
|
|
|
390
395
|
if (vm._hasHookEvent) {
|
|
391
396
|
vm.$emit('hook:' + hook)
|
|
392
397
|
}
|
|
393
|
-
setCurrentInstance(prev)
|
|
398
|
+
setContext && setCurrentInstance(prev)
|
|
394
399
|
popTarget()
|
|
395
400
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _Set as Set, isObject, isArray } from '../util/index'
|
|
2
2
|
import type { SimpleSet } from '../util/index'
|
|
3
3
|
import VNode from '../vdom/vnode'
|
|
4
|
+
import { isRef } from '../../v3'
|
|
4
5
|
|
|
5
6
|
const seenObjects = new Set()
|
|
6
7
|
|
|
@@ -35,6 +36,8 @@ function _traverse(val: any, seen: SimpleSet) {
|
|
|
35
36
|
if (isA) {
|
|
36
37
|
i = val.length
|
|
37
38
|
while (i--) _traverse(val[i], seen)
|
|
39
|
+
} else if (isRef(val)) {
|
|
40
|
+
_traverse(val.value, seen)
|
|
38
41
|
} else {
|
|
39
42
|
keys = Object.keys(val)
|
|
40
43
|
i = keys.length
|
package/src/core/util/debug.ts
CHANGED
|
@@ -2,6 +2,7 @@ import config from '../config'
|
|
|
2
2
|
import { noop, isArray, isFunction } from 'shared/util'
|
|
3
3
|
import type { Component } from 'types/component'
|
|
4
4
|
import { currentInstance } from 'v3/currentInstance'
|
|
5
|
+
import { getComponentName } from '../vdom/create-component'
|
|
5
6
|
|
|
6
7
|
export let warn: (msg: string, vm?: Component | null) => void = noop
|
|
7
8
|
export let tip = noop
|
|
@@ -40,7 +41,7 @@ if (__DEV__) {
|
|
|
40
41
|
: vm._isVue
|
|
41
42
|
? vm.$options || (vm.constructor as any).options
|
|
42
43
|
: vm
|
|
43
|
-
let name = options
|
|
44
|
+
let name = getComponentName(options)
|
|
44
45
|
const file = options.__file
|
|
45
46
|
if (!name && file) {
|
|
46
47
|
const match = file.match(/([^/\\]+)\.vue$/)
|
|
@@ -28,6 +28,10 @@ import type {
|
|
|
28
28
|
import type { Component } from 'types/component'
|
|
29
29
|
import type { ComponentOptions, InternalComponentOptions } from 'types/options'
|
|
30
30
|
|
|
31
|
+
export function getComponentName(options: ComponentOptions) {
|
|
32
|
+
return options.name || options.__name || options._componentTag
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
// inline hooks to be invoked on component VNodes during patch
|
|
32
36
|
const componentVNodeHooks = {
|
|
33
37
|
init(vnode: VNodeWithData, hydrating: boolean): boolean | void {
|
|
@@ -188,7 +192,7 @@ export function createComponent(
|
|
|
188
192
|
|
|
189
193
|
// return a placeholder vnode
|
|
190
194
|
// @ts-expect-error
|
|
191
|
-
const name = Ctor.options
|
|
195
|
+
const name = getComponentName(Ctor.options) || tag
|
|
192
196
|
const vnode = new VNode(
|
|
193
197
|
// @ts-expect-error
|
|
194
198
|
`vue-component-${Ctor.cid}${name ? `-${name}` : ''}`,
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
} from 'web/runtime/transition-util'
|
|
24
24
|
import VNode from 'core/vdom/vnode'
|
|
25
25
|
import { VNodeWithData } from 'types/vnode'
|
|
26
|
+
import { getComponentName } from 'core/vdom/create-component'
|
|
26
27
|
|
|
27
28
|
const props = extend(
|
|
28
29
|
{
|
|
@@ -72,7 +73,7 @@ export default {
|
|
|
72
73
|
} else if (__DEV__) {
|
|
73
74
|
const opts = c.componentOptions
|
|
74
75
|
const name: string = opts
|
|
75
|
-
? opts.Ctor.options
|
|
76
|
+
? getComponentName(opts.Ctor.options as any) || opts.tag || ''
|
|
76
77
|
: c.tag
|
|
77
78
|
warn(`<transition-group> children must be keyed: <${name}>`)
|
|
78
79
|
}
|
package/src/v3/apiWatch.ts
CHANGED
|
@@ -196,12 +196,10 @@ function doWatch(
|
|
|
196
196
|
getter = () => source.value
|
|
197
197
|
forceTrigger = isShallow(source)
|
|
198
198
|
} else if (isReactive(source)) {
|
|
199
|
-
getter =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
: () => source
|
|
199
|
+
getter = () => {
|
|
200
|
+
;(source as any).__ob__.dep.depend()
|
|
201
|
+
return source
|
|
202
|
+
}
|
|
205
203
|
deep = true
|
|
206
204
|
} else if (isArray(source)) {
|
|
207
205
|
isMultiSource = true
|
package/src/v3/reactivity/ref.ts
CHANGED
|
@@ -68,7 +68,7 @@ function createRef(rawValue: unknown, shallow: boolean) {
|
|
|
68
68
|
}
|
|
69
69
|
const ref: any = {}
|
|
70
70
|
def(ref, RefFlag, true)
|
|
71
|
-
def(ref, ReactiveFlags.IS_SHALLOW,
|
|
71
|
+
def(ref, ReactiveFlags.IS_SHALLOW, shallow)
|
|
72
72
|
def(
|
|
73
73
|
ref,
|
|
74
74
|
'dep',
|
|
@@ -119,7 +119,16 @@ export function proxyWithRefUnwrap(
|
|
|
119
119
|
Object.defineProperty(target, key, {
|
|
120
120
|
enumerable: true,
|
|
121
121
|
configurable: true,
|
|
122
|
-
get: () =>
|
|
122
|
+
get: () => {
|
|
123
|
+
const val = source[key]
|
|
124
|
+
if (isRef(val)) {
|
|
125
|
+
return val.value
|
|
126
|
+
} else {
|
|
127
|
+
const ob = val && val.__ob__
|
|
128
|
+
if (ob) ob.dep.depend()
|
|
129
|
+
return val
|
|
130
|
+
}
|
|
131
|
+
},
|
|
123
132
|
set: value => {
|
|
124
133
|
const oldValue = source[key]
|
|
125
134
|
if (isRef(oldValue) && !isRef(value)) {
|
package/types/options.d.ts
CHANGED
|
@@ -219,6 +219,8 @@ export interface ComponentOptions<
|
|
|
219
219
|
parent?: Vue
|
|
220
220
|
mixins?: (ComponentOptions<Vue> | typeof Vue)[]
|
|
221
221
|
name?: string
|
|
222
|
+
// for SFC auto name inference w/ ts-loader check
|
|
223
|
+
__name?: string
|
|
222
224
|
// TODO: support properly inferred 'extends'
|
|
223
225
|
extends?: ComponentOptions<Vue> | typeof Vue
|
|
224
226
|
delimiters?: [string, string]
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from './v3-generated'
|
|
6
6
|
import { UnionToIntersection } from './common'
|
|
7
7
|
|
|
8
|
-
import { Vue,
|
|
8
|
+
import { Vue, VueConstructor } from './vue'
|
|
9
9
|
import {
|
|
10
10
|
ComputedOptions,
|
|
11
11
|
MethodOptions,
|
|
@@ -13,8 +13,7 @@ import {
|
|
|
13
13
|
ComponentOptionsMixin,
|
|
14
14
|
ComponentOptionsBase
|
|
15
15
|
} from './v3-component-options'
|
|
16
|
-
import { EmitFn, EmitsOptions
|
|
17
|
-
import { VNode } from './vnode'
|
|
16
|
+
import { EmitFn, EmitsOptions } from './v3-setup-context'
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* Custom properties added to component instances in any way and can be accessed through `this`
|
|
@@ -173,18 +172,19 @@ interface Vue3Instance<
|
|
|
173
172
|
Defaults,
|
|
174
173
|
MakeDefaultsOptional,
|
|
175
174
|
Options
|
|
176
|
-
> extends
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
175
|
+
> extends Vue<
|
|
176
|
+
D,
|
|
177
|
+
Readonly<
|
|
178
|
+
MakeDefaultsOptional extends true
|
|
179
|
+
? Partial<Defaults> & Omit<P & PublicProps, keyof Defaults>
|
|
180
|
+
: P & PublicProps
|
|
181
|
+
>,
|
|
182
|
+
ComponentPublicInstance | null,
|
|
183
|
+
ComponentPublicInstance,
|
|
184
|
+
ComponentPublicInstance[],
|
|
185
|
+
Options & MergedComponentOptionsOverride,
|
|
186
|
+
EmitFn<E>
|
|
187
|
+
> {}
|
|
188
188
|
|
|
189
189
|
type MergedHook<T = () => void> = T | T[]
|
|
190
190
|
|
package/types/vue.d.ts
CHANGED
|
@@ -35,17 +35,25 @@ export interface CreateElement {
|
|
|
35
35
|
): VNode
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export interface Vue
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
export interface Vue<
|
|
39
|
+
Data = Record<string, any>,
|
|
40
|
+
Props = Record<string, any>,
|
|
41
|
+
Parent = never,
|
|
42
|
+
Root = never,
|
|
43
|
+
Children = never,
|
|
44
|
+
Options = never,
|
|
45
|
+
Emit = (event: string, ...args: any[]) => Vue
|
|
46
|
+
> {
|
|
47
|
+
// properties with different types in defineComponent()
|
|
48
|
+
readonly $data: Data
|
|
49
|
+
readonly $props: Props
|
|
50
|
+
readonly $parent: Parent extends never ? Vue : Parent
|
|
51
|
+
readonly $root: Root extends never ? Vue : Root
|
|
52
|
+
readonly $children: Children extends never ? Vue[] : Children
|
|
44
53
|
readonly $options: ComponentOptions<Vue>
|
|
45
|
-
$emit
|
|
46
|
-
}
|
|
54
|
+
$emit: Emit
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
// Vue 2 only or shared
|
|
49
57
|
readonly $el: Element
|
|
50
58
|
readonly $refs: {
|
|
51
59
|
[key: string]: Vue | Element | (Vue | Element)[] | undefined
|