vue 2.7.5 → 2.7.8
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 +107 -52
- package/dist/vue.common.prod.js +3 -3
- package/dist/vue.esm.browser.js +107 -53
- package/dist/vue.esm.browser.min.js +3 -3
- package/dist/vue.esm.js +107 -53
- package/dist/vue.js +107 -52
- package/dist/vue.min.js +3 -3
- package/dist/vue.runtime.common.dev.js +80 -43
- package/dist/vue.runtime.common.prod.js +3 -3
- package/dist/vue.runtime.esm.js +80 -44
- package/dist/vue.runtime.js +80 -43
- package/dist/vue.runtime.min.js +3 -3
- package/package.json +2 -2
- package/packages/compiler-sfc/dist/compiler-sfc.js +42 -23
- package/packages/compiler-sfc/package.json +2 -3
- package/packages/compiler-sfc/src/compileTemplate.ts +1 -2
- package/src/compiler/codegen/index.ts +31 -10
- package/src/core/instance/inject.ts +10 -5
- package/src/core/instance/lifecycle.ts +18 -10
- package/src/core/instance/render.ts +8 -2
- package/src/core/observer/index.ts +1 -1
- package/src/core/observer/scheduler.ts +10 -1
- package/src/core/observer/watcher.ts +2 -0
- package/src/types/component.ts +1 -0
- package/src/v3/apiInject.ts +17 -12
- package/src/v3/apiSetup.ts +38 -17
- package/src/v3/apiWatch.ts +1 -1
- package/src/v3/index.ts +1 -1
- package/types/index.d.ts +1 -1
- package/types/v3-component-public-instance.d.ts +0 -2
- package/types/v3-generated.d.ts +2 -0
- package/types/v3-manual-apis.d.ts +2 -2
- package/types/v3-setup-context.d.ts +5 -0
- package/types/vue.d.ts +13 -8
package/dist/vue.esm.browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vue.js v2.7.
|
|
2
|
+
* Vue.js v2.7.8
|
|
3
3
|
* (c) 2014-2022 Evan You
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -959,7 +959,7 @@ function defineReactive(obj, key, val, customSetter, shallow, mock) {
|
|
|
959
959
|
// #7981: for accessor properties without setter
|
|
960
960
|
return;
|
|
961
961
|
}
|
|
962
|
-
else if (isRef(value) && !isRef(newVal)) {
|
|
962
|
+
else if (!shallow && isRef(value) && !isRef(newVal)) {
|
|
963
963
|
value.value = newVal;
|
|
964
964
|
return;
|
|
965
965
|
}
|
|
@@ -2232,7 +2232,19 @@ function createSetupContext(vm) {
|
|
|
2232
2232
|
let exposeCalled = false;
|
|
2233
2233
|
return {
|
|
2234
2234
|
get attrs() {
|
|
2235
|
-
|
|
2235
|
+
if (!vm._attrsProxy) {
|
|
2236
|
+
const proxy = (vm._attrsProxy = {});
|
|
2237
|
+
def(proxy, '_v_attr_proxy', true);
|
|
2238
|
+
syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
|
|
2239
|
+
}
|
|
2240
|
+
return vm._attrsProxy;
|
|
2241
|
+
},
|
|
2242
|
+
get listeners() {
|
|
2243
|
+
if (!vm._listenersProxy) {
|
|
2244
|
+
const proxy = (vm._listenersProxy = {});
|
|
2245
|
+
syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
|
|
2246
|
+
}
|
|
2247
|
+
return vm._listenersProxy;
|
|
2236
2248
|
},
|
|
2237
2249
|
get slots() {
|
|
2238
2250
|
return initSlotsProxy(vm);
|
|
@@ -2251,20 +2263,12 @@ function createSetupContext(vm) {
|
|
|
2251
2263
|
}
|
|
2252
2264
|
};
|
|
2253
2265
|
}
|
|
2254
|
-
function
|
|
2255
|
-
if (!vm._attrsProxy) {
|
|
2256
|
-
const proxy = (vm._attrsProxy = {});
|
|
2257
|
-
def(proxy, '_v_attr_proxy', true);
|
|
2258
|
-
syncSetupAttrs(proxy, vm.$attrs, emptyObject, vm);
|
|
2259
|
-
}
|
|
2260
|
-
return vm._attrsProxy;
|
|
2261
|
-
}
|
|
2262
|
-
function syncSetupAttrs(to, from, prev, instance) {
|
|
2266
|
+
function syncSetupProxy(to, from, prev, instance, type) {
|
|
2263
2267
|
let changed = false;
|
|
2264
2268
|
for (const key in from) {
|
|
2265
2269
|
if (!(key in to)) {
|
|
2266
2270
|
changed = true;
|
|
2267
|
-
defineProxyAttr(to, key, instance);
|
|
2271
|
+
defineProxyAttr(to, key, instance, type);
|
|
2268
2272
|
}
|
|
2269
2273
|
else if (from[key] !== prev[key]) {
|
|
2270
2274
|
changed = true;
|
|
@@ -2278,12 +2282,12 @@ function syncSetupAttrs(to, from, prev, instance) {
|
|
|
2278
2282
|
}
|
|
2279
2283
|
return changed;
|
|
2280
2284
|
}
|
|
2281
|
-
function defineProxyAttr(proxy, key, instance) {
|
|
2285
|
+
function defineProxyAttr(proxy, key, instance, type) {
|
|
2282
2286
|
Object.defineProperty(proxy, key, {
|
|
2283
2287
|
enumerable: true,
|
|
2284
2288
|
configurable: true,
|
|
2285
2289
|
get() {
|
|
2286
|
-
return instance
|
|
2290
|
+
return instance[type][key];
|
|
2287
2291
|
}
|
|
2288
2292
|
});
|
|
2289
2293
|
}
|
|
@@ -2304,17 +2308,27 @@ function syncSetupSlots(to, from) {
|
|
|
2304
2308
|
}
|
|
2305
2309
|
}
|
|
2306
2310
|
/**
|
|
2307
|
-
* @internal use manual type def
|
|
2311
|
+
* @internal use manual type def because public setup context type relies on
|
|
2312
|
+
* legacy VNode types
|
|
2308
2313
|
*/
|
|
2309
2314
|
function useSlots() {
|
|
2310
2315
|
return getContext().slots;
|
|
2311
2316
|
}
|
|
2312
2317
|
/**
|
|
2313
|
-
* @internal use manual type def
|
|
2318
|
+
* @internal use manual type def because public setup context type relies on
|
|
2319
|
+
* legacy VNode types
|
|
2314
2320
|
*/
|
|
2315
2321
|
function useAttrs() {
|
|
2316
2322
|
return getContext().attrs;
|
|
2317
2323
|
}
|
|
2324
|
+
/**
|
|
2325
|
+
* Vue 2 only
|
|
2326
|
+
* @internal use manual type def because public setup context type relies on
|
|
2327
|
+
* legacy VNode types
|
|
2328
|
+
*/
|
|
2329
|
+
function useListeners() {
|
|
2330
|
+
return getContext().listeners;
|
|
2331
|
+
}
|
|
2318
2332
|
function getContext() {
|
|
2319
2333
|
if (!currentInstance) {
|
|
2320
2334
|
warn$2(`useContext() called without active instance.`);
|
|
@@ -2358,7 +2372,9 @@ function initRender(vm) {
|
|
|
2358
2372
|
const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
|
|
2359
2373
|
const renderContext = parentVnode && parentVnode.context;
|
|
2360
2374
|
vm.$slots = resolveSlots(options._renderChildren, renderContext);
|
|
2361
|
-
vm.$scopedSlots =
|
|
2375
|
+
vm.$scopedSlots = parentVnode
|
|
2376
|
+
? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
|
|
2377
|
+
: emptyObject;
|
|
2362
2378
|
// bind the createElement fn to this instance
|
|
2363
2379
|
// so that we get proper render context inside it.
|
|
2364
2380
|
// args order: tag, data, children, normalizationType, alwaysNormalize
|
|
@@ -2392,7 +2408,7 @@ function renderMixin(Vue) {
|
|
|
2392
2408
|
Vue.prototype._render = function () {
|
|
2393
2409
|
const vm = this;
|
|
2394
2410
|
const { render, _parentVnode } = vm.$options;
|
|
2395
|
-
if (_parentVnode) {
|
|
2411
|
+
if (_parentVnode && vm._isMounted) {
|
|
2396
2412
|
vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
|
|
2397
2413
|
if (vm._slotsProxy) {
|
|
2398
2414
|
syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
|
|
@@ -2913,12 +2929,19 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
|
|
|
2913
2929
|
if (vm._attrsProxy) {
|
|
2914
2930
|
// force update if attrs are accessed and has changed since it may be
|
|
2915
2931
|
// passed to a child component.
|
|
2916
|
-
if (
|
|
2932
|
+
if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
|
|
2917
2933
|
needsForceUpdate = true;
|
|
2918
2934
|
}
|
|
2919
2935
|
}
|
|
2920
2936
|
vm.$attrs = attrs;
|
|
2921
|
-
|
|
2937
|
+
// update listeners
|
|
2938
|
+
listeners = listeners || emptyObject;
|
|
2939
|
+
const prevListeners = vm.$options._parentListeners;
|
|
2940
|
+
if (vm._listenersProxy) {
|
|
2941
|
+
syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
|
|
2942
|
+
}
|
|
2943
|
+
vm.$listeners = vm.$options._parentListeners = listeners;
|
|
2944
|
+
updateComponentListeners(vm, listeners, prevListeners);
|
|
2922
2945
|
// update props
|
|
2923
2946
|
if (propsData && vm.$options.props) {
|
|
2924
2947
|
toggleObserving(false);
|
|
@@ -2933,11 +2956,6 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
|
|
|
2933
2956
|
// keep a copy of raw propsData
|
|
2934
2957
|
vm.$options.propsData = propsData;
|
|
2935
2958
|
}
|
|
2936
|
-
// update listeners
|
|
2937
|
-
listeners = listeners || emptyObject;
|
|
2938
|
-
const oldListeners = vm.$options._parentListeners;
|
|
2939
|
-
vm.$options._parentListeners = listeners;
|
|
2940
|
-
updateComponentListeners(vm, listeners, oldListeners);
|
|
2941
2959
|
// resolve slots + force update if has children
|
|
2942
2960
|
if (needsForceUpdate) {
|
|
2943
2961
|
vm.$slots = resolveSlots(renderChildren, parentVnode.context);
|
|
@@ -3051,6 +3069,16 @@ if (inBrowser && !isIE) {
|
|
|
3051
3069
|
getNow = () => performance.now();
|
|
3052
3070
|
}
|
|
3053
3071
|
}
|
|
3072
|
+
const sortCompareFn = (a, b) => {
|
|
3073
|
+
if (a.post) {
|
|
3074
|
+
if (!b.post)
|
|
3075
|
+
return 1;
|
|
3076
|
+
}
|
|
3077
|
+
else if (b.post) {
|
|
3078
|
+
return -1;
|
|
3079
|
+
}
|
|
3080
|
+
return a.id - b.id;
|
|
3081
|
+
};
|
|
3054
3082
|
/**
|
|
3055
3083
|
* Flush both queues and run the watchers.
|
|
3056
3084
|
*/
|
|
@@ -3066,7 +3094,7 @@ function flushSchedulerQueue() {
|
|
|
3066
3094
|
// user watchers are created before the render watcher)
|
|
3067
3095
|
// 3. If a component is destroyed during a parent component's watcher run,
|
|
3068
3096
|
// its watchers can be skipped.
|
|
3069
|
-
queue.sort(
|
|
3097
|
+
queue.sort(sortCompareFn);
|
|
3070
3098
|
// do not cache length because more watchers might be pushed
|
|
3071
3099
|
// as we run existing watchers
|
|
3072
3100
|
for (index$1 = 0; index$1 < queue.length; index$1++) {
|
|
@@ -3329,7 +3357,7 @@ function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigge
|
|
|
3329
3357
|
watcher.update = watcher.run;
|
|
3330
3358
|
}
|
|
3331
3359
|
else if (flush === 'post') {
|
|
3332
|
-
watcher.
|
|
3360
|
+
watcher.post = true;
|
|
3333
3361
|
watcher.update = () => queueWatcher(watcher);
|
|
3334
3362
|
}
|
|
3335
3363
|
else {
|
|
@@ -3478,18 +3506,23 @@ function provide(key, value) {
|
|
|
3478
3506
|
}
|
|
3479
3507
|
}
|
|
3480
3508
|
else {
|
|
3481
|
-
let provides = currentInstance._provided;
|
|
3482
|
-
// by default an instance inherits its parent's provides object
|
|
3483
|
-
// but when it needs to provide values of its own, it creates its
|
|
3484
|
-
// own provides object using parent provides object as prototype.
|
|
3485
|
-
// this way in `inject` we can simply look up injections from direct
|
|
3486
|
-
// parent and let the prototype chain do the work.
|
|
3487
|
-
const parentProvides = currentInstance.$parent && currentInstance.$parent._provided;
|
|
3488
|
-
if (parentProvides === provides) {
|
|
3489
|
-
provides = currentInstance._provided = Object.create(parentProvides);
|
|
3490
|
-
}
|
|
3491
3509
|
// TS doesn't allow symbol as index type
|
|
3492
|
-
|
|
3510
|
+
resolveProvided(currentInstance)[key] = value;
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
function resolveProvided(vm) {
|
|
3514
|
+
// by default an instance inherits its parent's provides object
|
|
3515
|
+
// but when it needs to provide values of its own, it creates its
|
|
3516
|
+
// own provides object using parent provides object as prototype.
|
|
3517
|
+
// this way in `inject` we can simply look up injections from direct
|
|
3518
|
+
// parent and let the prototype chain do the work.
|
|
3519
|
+
const existing = vm._provided;
|
|
3520
|
+
const parentProvides = vm.$parent && vm.$parent._provided;
|
|
3521
|
+
if (parentProvides === existing) {
|
|
3522
|
+
return (vm._provided = Object.create(parentProvides));
|
|
3523
|
+
}
|
|
3524
|
+
else {
|
|
3525
|
+
return existing;
|
|
3493
3526
|
}
|
|
3494
3527
|
}
|
|
3495
3528
|
function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
|
@@ -3856,7 +3889,7 @@ const onRenderTriggered = createLifeCycle('renderTriggered');
|
|
|
3856
3889
|
/**
|
|
3857
3890
|
* Note: also update dist/vue.runtime.mjs when adding new exports to this file.
|
|
3858
3891
|
*/
|
|
3859
|
-
const version = '2.7.
|
|
3892
|
+
const version = '2.7.8';
|
|
3860
3893
|
/**
|
|
3861
3894
|
* @internal type is manually declared in <root>/types/v3-define-component.d.ts
|
|
3862
3895
|
*/
|
|
@@ -3939,6 +3972,7 @@ class Watcher {
|
|
|
3939
3972
|
this.cb = cb;
|
|
3940
3973
|
this.id = ++uid$1; // uid for batching
|
|
3941
3974
|
this.active = true;
|
|
3975
|
+
this.post = false;
|
|
3942
3976
|
this.dirty = this.lazy; // for lazy watchers
|
|
3943
3977
|
this.deps = [];
|
|
3944
3978
|
this.newDeps = [];
|
|
@@ -4403,12 +4437,14 @@ function initProvide(vm) {
|
|
|
4403
4437
|
if (!isObject(provided)) {
|
|
4404
4438
|
return;
|
|
4405
4439
|
}
|
|
4440
|
+
const source = resolveProvided(vm);
|
|
4441
|
+
// IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
|
|
4442
|
+
// iterate the keys ourselves.
|
|
4406
4443
|
const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
|
|
4407
|
-
setCurrentInstance(vm);
|
|
4408
4444
|
for (let i = 0; i < keys.length; i++) {
|
|
4409
|
-
|
|
4445
|
+
const key = keys[i];
|
|
4446
|
+
Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
|
|
4410
4447
|
}
|
|
4411
|
-
setCurrentInstance();
|
|
4412
4448
|
}
|
|
4413
4449
|
}
|
|
4414
4450
|
function initInjections(vm) {
|
|
@@ -10741,17 +10777,15 @@ function genElement(el, state) {
|
|
|
10741
10777
|
}
|
|
10742
10778
|
else {
|
|
10743
10779
|
let data;
|
|
10744
|
-
|
|
10780
|
+
const maybeComponent = state.maybeComponent(el);
|
|
10781
|
+
if (!el.plain || (el.pre && maybeComponent)) {
|
|
10745
10782
|
data = genData(el, state);
|
|
10746
10783
|
}
|
|
10747
10784
|
let tag;
|
|
10748
10785
|
// check if this is a component in <script setup>
|
|
10749
10786
|
const bindings = state.options.bindings;
|
|
10750
|
-
if (bindings && bindings.__isScriptSetup !== false) {
|
|
10751
|
-
tag =
|
|
10752
|
-
checkBindingType(bindings, el.tag) ||
|
|
10753
|
-
checkBindingType(bindings, camelize(el.tag)) ||
|
|
10754
|
-
checkBindingType(bindings, capitalize(camelize(el.tag)));
|
|
10787
|
+
if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
|
|
10788
|
+
tag = checkBindingType(bindings, el.tag);
|
|
10755
10789
|
}
|
|
10756
10790
|
if (!tag)
|
|
10757
10791
|
tag = `'${el.tag}'`;
|
|
@@ -10768,9 +10802,29 @@ function genElement(el, state) {
|
|
|
10768
10802
|
}
|
|
10769
10803
|
}
|
|
10770
10804
|
function checkBindingType(bindings, key) {
|
|
10771
|
-
const
|
|
10772
|
-
|
|
10773
|
-
|
|
10805
|
+
const camelName = camelize(key);
|
|
10806
|
+
const PascalName = capitalize(camelName);
|
|
10807
|
+
const checkType = (type) => {
|
|
10808
|
+
if (bindings[key] === type) {
|
|
10809
|
+
return key;
|
|
10810
|
+
}
|
|
10811
|
+
if (bindings[camelName] === type) {
|
|
10812
|
+
return camelName;
|
|
10813
|
+
}
|
|
10814
|
+
if (bindings[PascalName] === type) {
|
|
10815
|
+
return PascalName;
|
|
10816
|
+
}
|
|
10817
|
+
};
|
|
10818
|
+
const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
|
|
10819
|
+
checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
|
|
10820
|
+
if (fromConst) {
|
|
10821
|
+
return fromConst;
|
|
10822
|
+
}
|
|
10823
|
+
const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
|
|
10824
|
+
checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
|
|
10825
|
+
checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
|
|
10826
|
+
if (fromMaybeRef) {
|
|
10827
|
+
return fromMaybeRef;
|
|
10774
10828
|
}
|
|
10775
10829
|
}
|
|
10776
10830
|
// hoist static sub-trees out
|
|
@@ -11589,4 +11643,4 @@ function getOuterHTML(el) {
|
|
|
11589
11643
|
}
|
|
11590
11644
|
Vue.compile = compileToFunctions;
|
|
11591
11645
|
|
|
11592
|
-
export { EffectScope, computed, customRef, Vue as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref$1 as ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };
|
|
11646
|
+
export { EffectScope, computed, customRef, Vue as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref$1 as ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useListeners, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };
|