vue 2.7.7 → 2.7.10
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/README.md +1 -1
- package/dist/vue.common.dev.js +105 -49
- package/dist/vue.common.prod.js +3 -3
- package/dist/vue.esm.browser.js +103 -48
- package/dist/vue.esm.browser.min.js +3 -3
- package/dist/vue.esm.js +104 -48
- package/dist/vue.js +106 -49
- package/dist/vue.min.js +3 -3
- package/dist/vue.runtime.common.dev.js +81 -42
- package/dist/vue.runtime.common.prod.js +3 -3
- package/dist/vue.runtime.esm.js +80 -41
- package/dist/vue.runtime.js +82 -42
- package/dist/vue.runtime.min.js +3 -3
- package/package.json +2 -2
- package/packages/compiler-sfc/dist/compiler-sfc.js +55 -26
- package/packages/compiler-sfc/package.json +2 -3
- package/packages/compiler-sfc/src/compileTemplate.ts +1 -2
- package/packages/compiler-sfc/src/parseComponent.ts +2 -2
- package/packages/compiler-sfc/src/rewriteDefault.ts +6 -1
- package/packages/compiler-sfc/src/templateCompilerModules/utils.ts +8 -3
- package/packages/compiler-sfc/test/rewriteDefault.spec.ts +245 -0
- package/src/compiler/codegen/index.ts +28 -8
- package/src/core/instance/init.ts +1 -0
- package/src/core/instance/lifecycle.ts +27 -12
- package/src/core/instance/proxy.ts +2 -2
- package/src/core/instance/state.ts +1 -1
- package/src/core/observer/index.ts +1 -1
- package/src/core/observer/watcher.ts +12 -5
- package/src/core/vdom/modules/directives.ts +9 -1
- package/src/core/vdom/vnode.ts +1 -0
- package/src/types/component.ts +1 -0
- package/src/v3/apiLifecycle.ts +16 -1
- package/src/v3/apiSetup.ts +38 -17
- package/src/v3/apiWatch.ts +1 -4
- package/src/v3/index.ts +1 -1
- package/src/v3/reactivity/effectScope.ts +5 -1
- package/types/index.d.ts +2 -2
- package/types/options.d.ts +24 -9
- package/types/v3-component-options.d.ts +3 -0
- package/types/v3-component-public-instance.d.ts +2 -4
- package/types/v3-define-component.d.ts +34 -34
- package/types/v3-generated.d.ts +11 -2
- package/types/v3-manual-apis.d.ts +2 -2
- package/types/v3-setup-context.d.ts +4 -0
- package/types/vue.d.ts +108 -31
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vue.js v2.7.
|
|
2
|
+
* Vue.js v2.7.10
|
|
3
3
|
* (c) 2014-2022 Evan You
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -874,7 +874,7 @@ function defineReactive(obj, key, val, customSetter, shallow, mock) {
|
|
|
874
874
|
// #7981: for accessor properties without setter
|
|
875
875
|
return;
|
|
876
876
|
}
|
|
877
|
-
else if (isRef(value) && !isRef(newVal)) {
|
|
877
|
+
else if (!shallow && isRef(value) && !isRef(newVal)) {
|
|
878
878
|
value.value = newVal;
|
|
879
879
|
return;
|
|
880
880
|
}
|
|
@@ -1446,8 +1446,7 @@ function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigge
|
|
|
1446
1446
|
let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
|
|
1447
1447
|
// overwrite default run
|
|
1448
1448
|
watcher.run = () => {
|
|
1449
|
-
if (!watcher.active
|
|
1450
|
-
!(flush === 'pre' && instance && instance._isBeingDestroyed)) {
|
|
1449
|
+
if (!watcher.active) {
|
|
1451
1450
|
return;
|
|
1452
1451
|
}
|
|
1453
1452
|
if (cb) {
|
|
@@ -2365,7 +2364,19 @@ function createSetupContext(vm) {
|
|
|
2365
2364
|
let exposeCalled = false;
|
|
2366
2365
|
return {
|
|
2367
2366
|
get attrs() {
|
|
2368
|
-
|
|
2367
|
+
if (!vm._attrsProxy) {
|
|
2368
|
+
const proxy = (vm._attrsProxy = {});
|
|
2369
|
+
def(proxy, '_v_attr_proxy', true);
|
|
2370
|
+
syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
|
|
2371
|
+
}
|
|
2372
|
+
return vm._attrsProxy;
|
|
2373
|
+
},
|
|
2374
|
+
get listeners() {
|
|
2375
|
+
if (!vm._listenersProxy) {
|
|
2376
|
+
const proxy = (vm._listenersProxy = {});
|
|
2377
|
+
syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
|
|
2378
|
+
}
|
|
2379
|
+
return vm._listenersProxy;
|
|
2369
2380
|
},
|
|
2370
2381
|
get slots() {
|
|
2371
2382
|
return initSlotsProxy(vm);
|
|
@@ -2384,20 +2395,12 @@ function createSetupContext(vm) {
|
|
|
2384
2395
|
}
|
|
2385
2396
|
};
|
|
2386
2397
|
}
|
|
2387
|
-
function
|
|
2388
|
-
if (!vm._attrsProxy) {
|
|
2389
|
-
const proxy = (vm._attrsProxy = {});
|
|
2390
|
-
def(proxy, '_v_attr_proxy', true);
|
|
2391
|
-
syncSetupAttrs(proxy, vm.$attrs, emptyObject, vm);
|
|
2392
|
-
}
|
|
2393
|
-
return vm._attrsProxy;
|
|
2394
|
-
}
|
|
2395
|
-
function syncSetupAttrs(to, from, prev, instance) {
|
|
2398
|
+
function syncSetupProxy(to, from, prev, instance, type) {
|
|
2396
2399
|
let changed = false;
|
|
2397
2400
|
for (const key in from) {
|
|
2398
2401
|
if (!(key in to)) {
|
|
2399
2402
|
changed = true;
|
|
2400
|
-
defineProxyAttr(to, key, instance);
|
|
2403
|
+
defineProxyAttr(to, key, instance, type);
|
|
2401
2404
|
}
|
|
2402
2405
|
else if (from[key] !== prev[key]) {
|
|
2403
2406
|
changed = true;
|
|
@@ -2411,12 +2414,12 @@ function syncSetupAttrs(to, from, prev, instance) {
|
|
|
2411
2414
|
}
|
|
2412
2415
|
return changed;
|
|
2413
2416
|
}
|
|
2414
|
-
function defineProxyAttr(proxy, key, instance) {
|
|
2417
|
+
function defineProxyAttr(proxy, key, instance, type) {
|
|
2415
2418
|
Object.defineProperty(proxy, key, {
|
|
2416
2419
|
enumerable: true,
|
|
2417
2420
|
configurable: true,
|
|
2418
2421
|
get() {
|
|
2419
|
-
return instance
|
|
2422
|
+
return instance[type][key];
|
|
2420
2423
|
}
|
|
2421
2424
|
});
|
|
2422
2425
|
}
|
|
@@ -2437,17 +2440,27 @@ function syncSetupSlots(to, from) {
|
|
|
2437
2440
|
}
|
|
2438
2441
|
}
|
|
2439
2442
|
/**
|
|
2440
|
-
* @internal use manual type def
|
|
2443
|
+
* @internal use manual type def because public setup context type relies on
|
|
2444
|
+
* legacy VNode types
|
|
2441
2445
|
*/
|
|
2442
2446
|
function useSlots() {
|
|
2443
2447
|
return getContext().slots;
|
|
2444
2448
|
}
|
|
2445
2449
|
/**
|
|
2446
|
-
* @internal use manual type def
|
|
2450
|
+
* @internal use manual type def because public setup context type relies on
|
|
2451
|
+
* legacy VNode types
|
|
2447
2452
|
*/
|
|
2448
2453
|
function useAttrs() {
|
|
2449
2454
|
return getContext().attrs;
|
|
2450
2455
|
}
|
|
2456
|
+
/**
|
|
2457
|
+
* Vue 2 only
|
|
2458
|
+
* @internal use manual type def because public setup context type relies on
|
|
2459
|
+
* legacy VNode types
|
|
2460
|
+
*/
|
|
2461
|
+
function useListeners() {
|
|
2462
|
+
return getContext().listeners;
|
|
2463
|
+
}
|
|
2451
2464
|
function getContext() {
|
|
2452
2465
|
if (!currentInstance) {
|
|
2453
2466
|
warn(`useContext() called without active instance.`);
|
|
@@ -3162,17 +3175,20 @@ const onBeforeUpdate = createLifeCycle('beforeUpdate');
|
|
|
3162
3175
|
const onUpdated = createLifeCycle('updated');
|
|
3163
3176
|
const onBeforeUnmount = createLifeCycle('beforeDestroy');
|
|
3164
3177
|
const onUnmounted = createLifeCycle('destroyed');
|
|
3165
|
-
const onErrorCaptured = createLifeCycle('errorCaptured');
|
|
3166
3178
|
const onActivated = createLifeCycle('activated');
|
|
3167
3179
|
const onDeactivated = createLifeCycle('deactivated');
|
|
3168
3180
|
const onServerPrefetch = createLifeCycle('serverPrefetch');
|
|
3169
3181
|
const onRenderTracked = createLifeCycle('renderTracked');
|
|
3170
|
-
const onRenderTriggered = createLifeCycle('renderTriggered');
|
|
3182
|
+
const onRenderTriggered = createLifeCycle('renderTriggered');
|
|
3183
|
+
const injectErrorCapturedHook = createLifeCycle('errorCaptured');
|
|
3184
|
+
function onErrorCaptured(hook, target = currentInstance) {
|
|
3185
|
+
injectErrorCapturedHook(hook, target);
|
|
3186
|
+
}
|
|
3171
3187
|
|
|
3172
3188
|
/**
|
|
3173
3189
|
* Note: also update dist/vue.runtime.mjs when adding new exports to this file.
|
|
3174
3190
|
*/
|
|
3175
|
-
const version = '2.7.
|
|
3191
|
+
const version = '2.7.10';
|
|
3176
3192
|
/**
|
|
3177
3193
|
* @internal type is manually declared in <root>/types/v3-define-component.d.ts
|
|
3178
3194
|
*/
|
|
@@ -3218,6 +3234,7 @@ var vca = /*#__PURE__*/Object.freeze({
|
|
|
3218
3234
|
getCurrentInstance: getCurrentInstance,
|
|
3219
3235
|
useSlots: useSlots,
|
|
3220
3236
|
useAttrs: useAttrs,
|
|
3237
|
+
useListeners: useListeners,
|
|
3221
3238
|
mergeDefaults: mergeDefaults,
|
|
3222
3239
|
nextTick: nextTick,
|
|
3223
3240
|
set: set,
|
|
@@ -3231,12 +3248,12 @@ var vca = /*#__PURE__*/Object.freeze({
|
|
|
3231
3248
|
onUpdated: onUpdated,
|
|
3232
3249
|
onBeforeUnmount: onBeforeUnmount,
|
|
3233
3250
|
onUnmounted: onUnmounted,
|
|
3234
|
-
onErrorCaptured: onErrorCaptured,
|
|
3235
3251
|
onActivated: onActivated,
|
|
3236
3252
|
onDeactivated: onDeactivated,
|
|
3237
3253
|
onServerPrefetch: onServerPrefetch,
|
|
3238
3254
|
onRenderTracked: onRenderTracked,
|
|
3239
|
-
onRenderTriggered: onRenderTriggered
|
|
3255
|
+
onRenderTriggered: onRenderTriggered,
|
|
3256
|
+
onErrorCaptured: onErrorCaptured
|
|
3240
3257
|
});
|
|
3241
3258
|
|
|
3242
3259
|
const seenObjects = new _Set();
|
|
@@ -3290,11 +3307,16 @@ let uid$1 = 0;
|
|
|
3290
3307
|
*/
|
|
3291
3308
|
class Watcher {
|
|
3292
3309
|
constructor(vm, expOrFn, cb, options, isRenderWatcher) {
|
|
3293
|
-
recordEffectScope(this,
|
|
3294
|
-
if (
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3310
|
+
recordEffectScope(this,
|
|
3311
|
+
// if the active effect scope is manually created (not a component scope),
|
|
3312
|
+
// prioritize it
|
|
3313
|
+
activeEffectScope && !activeEffectScope._vm
|
|
3314
|
+
? activeEffectScope
|
|
3315
|
+
: vm
|
|
3316
|
+
? vm._scope
|
|
3317
|
+
: undefined);
|
|
3318
|
+
if ((this.vm = vm) && isRenderWatcher) {
|
|
3319
|
+
vm._watcher = this;
|
|
3298
3320
|
}
|
|
3299
3321
|
// options
|
|
3300
3322
|
if (options) {
|
|
@@ -3677,8 +3699,13 @@ function lifecycleMixin(Vue) {
|
|
|
3677
3699
|
vm.$el.__vue__ = vm;
|
|
3678
3700
|
}
|
|
3679
3701
|
// if parent is an HOC, update its $el as well
|
|
3680
|
-
|
|
3681
|
-
|
|
3702
|
+
let wrapper = vm;
|
|
3703
|
+
while (wrapper &&
|
|
3704
|
+
wrapper.$vnode &&
|
|
3705
|
+
wrapper.$parent &&
|
|
3706
|
+
wrapper.$vnode === wrapper.$parent._vnode) {
|
|
3707
|
+
wrapper.$parent.$el = wrapper.$el;
|
|
3708
|
+
wrapper = wrapper.$parent;
|
|
3682
3709
|
}
|
|
3683
3710
|
// updated hook is called by the scheduler to ensure that children are
|
|
3684
3711
|
// updated in a parent's updated hook.
|
|
@@ -3837,12 +3864,19 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
|
|
|
3837
3864
|
if (vm._attrsProxy) {
|
|
3838
3865
|
// force update if attrs are accessed and has changed since it may be
|
|
3839
3866
|
// passed to a child component.
|
|
3840
|
-
if (
|
|
3867
|
+
if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
|
|
3841
3868
|
needsForceUpdate = true;
|
|
3842
3869
|
}
|
|
3843
3870
|
}
|
|
3844
3871
|
vm.$attrs = attrs;
|
|
3845
|
-
|
|
3872
|
+
// update listeners
|
|
3873
|
+
listeners = listeners || emptyObject;
|
|
3874
|
+
const prevListeners = vm.$options._parentListeners;
|
|
3875
|
+
if (vm._listenersProxy) {
|
|
3876
|
+
syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
|
|
3877
|
+
}
|
|
3878
|
+
vm.$listeners = vm.$options._parentListeners = listeners;
|
|
3879
|
+
updateComponentListeners(vm, listeners, prevListeners);
|
|
3846
3880
|
// update props
|
|
3847
3881
|
if (propsData && vm.$options.props) {
|
|
3848
3882
|
toggleObserving(false);
|
|
@@ -3857,11 +3891,6 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
|
|
|
3857
3891
|
// keep a copy of raw propsData
|
|
3858
3892
|
vm.$options.propsData = propsData;
|
|
3859
3893
|
}
|
|
3860
|
-
// update listeners
|
|
3861
|
-
listeners = listeners || emptyObject;
|
|
3862
|
-
const oldListeners = vm.$options._parentListeners;
|
|
3863
|
-
vm.$options._parentListeners = listeners;
|
|
3864
|
-
updateComponentListeners(vm, listeners, oldListeners);
|
|
3865
3894
|
// resolve slots + force update if has children
|
|
3866
3895
|
if (needsForceUpdate) {
|
|
3867
3896
|
vm.$slots = resolveSlots(renderChildren, parentVnode.context);
|
|
@@ -5140,13 +5169,13 @@ let initProxy;
|
|
|
5140
5169
|
'referenced during render. Make sure that this property is reactive, ' +
|
|
5141
5170
|
'either in the data option, or for class-based components, by ' +
|
|
5142
5171
|
'initializing the property. ' +
|
|
5143
|
-
'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
|
|
5172
|
+
'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
|
|
5144
5173
|
};
|
|
5145
5174
|
const warnReservedPrefix = (target, key) => {
|
|
5146
5175
|
warn(`Property "${key}" must be accessed with "$data.${key}" because ` +
|
|
5147
5176
|
'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
|
|
5148
5177
|
'prevent conflicts with Vue internals. ' +
|
|
5149
|
-
'See: https://vuejs.org/v2/api/#data', target);
|
|
5178
|
+
'See: https://v2.vuejs.org/v2/api/#data', target);
|
|
5150
5179
|
};
|
|
5151
5180
|
const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
|
|
5152
5181
|
if (hasProxy) {
|
|
@@ -5285,7 +5314,7 @@ function initData(vm) {
|
|
|
5285
5314
|
if (!isPlainObject(data)) {
|
|
5286
5315
|
data = {};
|
|
5287
5316
|
warn('data functions should return an object:\n' +
|
|
5288
|
-
'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
|
|
5317
|
+
'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
|
|
5289
5318
|
}
|
|
5290
5319
|
// proxy data on instance
|
|
5291
5320
|
const keys = Object.keys(data);
|
|
@@ -5517,6 +5546,7 @@ function initMixin$1(Vue) {
|
|
|
5517
5546
|
vm.__v_skip = true;
|
|
5518
5547
|
// effect scope
|
|
5519
5548
|
vm._scope = new EffectScope(true /* detached */);
|
|
5549
|
+
vm._scope._vm = true;
|
|
5520
5550
|
// merge options
|
|
5521
5551
|
if (options && options._isComponent) {
|
|
5522
5552
|
// optimize internal component instantiation
|
|
@@ -7087,7 +7117,16 @@ function normalizeDirectives(dirs, vm) {
|
|
|
7087
7117
|
}
|
|
7088
7118
|
res[getRawDirName(dir)] = dir;
|
|
7089
7119
|
if (vm._setupState && vm._setupState.__sfc) {
|
|
7090
|
-
|
|
7120
|
+
const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
|
|
7121
|
+
if (typeof setupDef === 'function') {
|
|
7122
|
+
dir.def = {
|
|
7123
|
+
bind: setupDef,
|
|
7124
|
+
update: setupDef,
|
|
7125
|
+
};
|
|
7126
|
+
}
|
|
7127
|
+
else {
|
|
7128
|
+
dir.def = setupDef;
|
|
7129
|
+
}
|
|
7091
7130
|
}
|
|
7092
7131
|
dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
|
|
7093
7132
|
}
|