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
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ Vue.js supports all browsers that are [ES5-compliant](https://kangax.github.io/c
|
|
|
73
73
|
|
|
74
74
|
## Documentation
|
|
75
75
|
|
|
76
|
-
To check out [live examples](https://vuejs.org/v2/examples/) and docs, visit [vuejs.org](https://vuejs.org).
|
|
76
|
+
To check out [live examples](https://v2.vuejs.org/v2/examples/) and docs, visit [vuejs.org](https://v2.vuejs.org).
|
|
77
77
|
|
|
78
78
|
## Questions
|
|
79
79
|
|
package/dist/vue.common.dev.js
CHANGED
|
@@ -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
|
*/
|
|
@@ -643,13 +643,13 @@ let initProxy;
|
|
|
643
643
|
'referenced during render. Make sure that this property is reactive, ' +
|
|
644
644
|
'either in the data option, or for class-based components, by ' +
|
|
645
645
|
'initializing the property. ' +
|
|
646
|
-
'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
|
|
646
|
+
'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
|
|
647
647
|
};
|
|
648
648
|
const warnReservedPrefix = (target, key) => {
|
|
649
649
|
warn$2(`Property "${key}" must be accessed with "$data.${key}" because ` +
|
|
650
650
|
'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
|
|
651
651
|
'prevent conflicts with Vue internals. ' +
|
|
652
|
-
'See: https://vuejs.org/v2/api/#data', target);
|
|
652
|
+
'See: https://v2.vuejs.org/v2/api/#data', target);
|
|
653
653
|
};
|
|
654
654
|
const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
|
|
655
655
|
if (hasProxy) {
|
|
@@ -961,7 +961,7 @@ function defineReactive(obj, key, val, customSetter, shallow, mock) {
|
|
|
961
961
|
// #7981: for accessor properties without setter
|
|
962
962
|
return;
|
|
963
963
|
}
|
|
964
|
-
else if (isRef(value) && !isRef(newVal)) {
|
|
964
|
+
else if (!shallow && isRef(value) && !isRef(newVal)) {
|
|
965
965
|
value.value = newVal;
|
|
966
966
|
return;
|
|
967
967
|
}
|
|
@@ -2234,7 +2234,19 @@ function createSetupContext(vm) {
|
|
|
2234
2234
|
let exposeCalled = false;
|
|
2235
2235
|
return {
|
|
2236
2236
|
get attrs() {
|
|
2237
|
-
|
|
2237
|
+
if (!vm._attrsProxy) {
|
|
2238
|
+
const proxy = (vm._attrsProxy = {});
|
|
2239
|
+
def(proxy, '_v_attr_proxy', true);
|
|
2240
|
+
syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
|
|
2241
|
+
}
|
|
2242
|
+
return vm._attrsProxy;
|
|
2243
|
+
},
|
|
2244
|
+
get listeners() {
|
|
2245
|
+
if (!vm._listenersProxy) {
|
|
2246
|
+
const proxy = (vm._listenersProxy = {});
|
|
2247
|
+
syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
|
|
2248
|
+
}
|
|
2249
|
+
return vm._listenersProxy;
|
|
2238
2250
|
},
|
|
2239
2251
|
get slots() {
|
|
2240
2252
|
return initSlotsProxy(vm);
|
|
@@ -2253,20 +2265,12 @@ function createSetupContext(vm) {
|
|
|
2253
2265
|
}
|
|
2254
2266
|
};
|
|
2255
2267
|
}
|
|
2256
|
-
function
|
|
2257
|
-
if (!vm._attrsProxy) {
|
|
2258
|
-
const proxy = (vm._attrsProxy = {});
|
|
2259
|
-
def(proxy, '_v_attr_proxy', true);
|
|
2260
|
-
syncSetupAttrs(proxy, vm.$attrs, emptyObject, vm);
|
|
2261
|
-
}
|
|
2262
|
-
return vm._attrsProxy;
|
|
2263
|
-
}
|
|
2264
|
-
function syncSetupAttrs(to, from, prev, instance) {
|
|
2268
|
+
function syncSetupProxy(to, from, prev, instance, type) {
|
|
2265
2269
|
let changed = false;
|
|
2266
2270
|
for (const key in from) {
|
|
2267
2271
|
if (!(key in to)) {
|
|
2268
2272
|
changed = true;
|
|
2269
|
-
defineProxyAttr(to, key, instance);
|
|
2273
|
+
defineProxyAttr(to, key, instance, type);
|
|
2270
2274
|
}
|
|
2271
2275
|
else if (from[key] !== prev[key]) {
|
|
2272
2276
|
changed = true;
|
|
@@ -2280,12 +2284,12 @@ function syncSetupAttrs(to, from, prev, instance) {
|
|
|
2280
2284
|
}
|
|
2281
2285
|
return changed;
|
|
2282
2286
|
}
|
|
2283
|
-
function defineProxyAttr(proxy, key, instance) {
|
|
2287
|
+
function defineProxyAttr(proxy, key, instance, type) {
|
|
2284
2288
|
Object.defineProperty(proxy, key, {
|
|
2285
2289
|
enumerable: true,
|
|
2286
2290
|
configurable: true,
|
|
2287
2291
|
get() {
|
|
2288
|
-
return instance
|
|
2292
|
+
return instance[type][key];
|
|
2289
2293
|
}
|
|
2290
2294
|
});
|
|
2291
2295
|
}
|
|
@@ -2306,17 +2310,27 @@ function syncSetupSlots(to, from) {
|
|
|
2306
2310
|
}
|
|
2307
2311
|
}
|
|
2308
2312
|
/**
|
|
2309
|
-
* @internal use manual type def
|
|
2313
|
+
* @internal use manual type def because public setup context type relies on
|
|
2314
|
+
* legacy VNode types
|
|
2310
2315
|
*/
|
|
2311
2316
|
function useSlots() {
|
|
2312
2317
|
return getContext().slots;
|
|
2313
2318
|
}
|
|
2314
2319
|
/**
|
|
2315
|
-
* @internal use manual type def
|
|
2320
|
+
* @internal use manual type def because public setup context type relies on
|
|
2321
|
+
* legacy VNode types
|
|
2316
2322
|
*/
|
|
2317
2323
|
function useAttrs() {
|
|
2318
2324
|
return getContext().attrs;
|
|
2319
2325
|
}
|
|
2326
|
+
/**
|
|
2327
|
+
* Vue 2 only
|
|
2328
|
+
* @internal use manual type def because public setup context type relies on
|
|
2329
|
+
* legacy VNode types
|
|
2330
|
+
*/
|
|
2331
|
+
function useListeners() {
|
|
2332
|
+
return getContext().listeners;
|
|
2333
|
+
}
|
|
2320
2334
|
function getContext() {
|
|
2321
2335
|
if (!currentInstance) {
|
|
2322
2336
|
warn$2(`useContext() called without active instance.`);
|
|
@@ -2757,8 +2771,13 @@ function lifecycleMixin(Vue) {
|
|
|
2757
2771
|
vm.$el.__vue__ = vm;
|
|
2758
2772
|
}
|
|
2759
2773
|
// if parent is an HOC, update its $el as well
|
|
2760
|
-
|
|
2761
|
-
|
|
2774
|
+
let wrapper = vm;
|
|
2775
|
+
while (wrapper &&
|
|
2776
|
+
wrapper.$vnode &&
|
|
2777
|
+
wrapper.$parent &&
|
|
2778
|
+
wrapper.$vnode === wrapper.$parent._vnode) {
|
|
2779
|
+
wrapper.$parent.$el = wrapper.$el;
|
|
2780
|
+
wrapper = wrapper.$parent;
|
|
2762
2781
|
}
|
|
2763
2782
|
// updated hook is called by the scheduler to ensure that children are
|
|
2764
2783
|
// updated in a parent's updated hook.
|
|
@@ -2917,12 +2936,19 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
|
|
|
2917
2936
|
if (vm._attrsProxy) {
|
|
2918
2937
|
// force update if attrs are accessed and has changed since it may be
|
|
2919
2938
|
// passed to a child component.
|
|
2920
|
-
if (
|
|
2939
|
+
if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
|
|
2921
2940
|
needsForceUpdate = true;
|
|
2922
2941
|
}
|
|
2923
2942
|
}
|
|
2924
2943
|
vm.$attrs = attrs;
|
|
2925
|
-
|
|
2944
|
+
// update listeners
|
|
2945
|
+
listeners = listeners || emptyObject;
|
|
2946
|
+
const prevListeners = vm.$options._parentListeners;
|
|
2947
|
+
if (vm._listenersProxy) {
|
|
2948
|
+
syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
|
|
2949
|
+
}
|
|
2950
|
+
vm.$listeners = vm.$options._parentListeners = listeners;
|
|
2951
|
+
updateComponentListeners(vm, listeners, prevListeners);
|
|
2926
2952
|
// update props
|
|
2927
2953
|
if (propsData && vm.$options.props) {
|
|
2928
2954
|
toggleObserving(false);
|
|
@@ -2937,11 +2963,6 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
|
|
|
2937
2963
|
// keep a copy of raw propsData
|
|
2938
2964
|
vm.$options.propsData = propsData;
|
|
2939
2965
|
}
|
|
2940
|
-
// update listeners
|
|
2941
|
-
listeners = listeners || emptyObject;
|
|
2942
|
-
const oldListeners = vm.$options._parentListeners;
|
|
2943
|
-
vm.$options._parentListeners = listeners;
|
|
2944
|
-
updateComponentListeners(vm, listeners, oldListeners);
|
|
2945
2966
|
// resolve slots + force update if has children
|
|
2946
2967
|
if (needsForceUpdate) {
|
|
2947
2968
|
vm.$slots = resolveSlots(renderChildren, parentVnode.context);
|
|
@@ -3309,8 +3330,7 @@ function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigge
|
|
|
3309
3330
|
let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
|
|
3310
3331
|
// overwrite default run
|
|
3311
3332
|
watcher.run = () => {
|
|
3312
|
-
if (!watcher.active
|
|
3313
|
-
!(flush === 'pre' && instance && instance._isBeingDestroyed)) {
|
|
3333
|
+
if (!watcher.active) {
|
|
3314
3334
|
return;
|
|
3315
3335
|
}
|
|
3316
3336
|
if (cb) {
|
|
@@ -3871,17 +3891,20 @@ const onBeforeUpdate = createLifeCycle('beforeUpdate');
|
|
|
3871
3891
|
const onUpdated = createLifeCycle('updated');
|
|
3872
3892
|
const onBeforeUnmount = createLifeCycle('beforeDestroy');
|
|
3873
3893
|
const onUnmounted = createLifeCycle('destroyed');
|
|
3874
|
-
const onErrorCaptured = createLifeCycle('errorCaptured');
|
|
3875
3894
|
const onActivated = createLifeCycle('activated');
|
|
3876
3895
|
const onDeactivated = createLifeCycle('deactivated');
|
|
3877
3896
|
const onServerPrefetch = createLifeCycle('serverPrefetch');
|
|
3878
3897
|
const onRenderTracked = createLifeCycle('renderTracked');
|
|
3879
|
-
const onRenderTriggered = createLifeCycle('renderTriggered');
|
|
3898
|
+
const onRenderTriggered = createLifeCycle('renderTriggered');
|
|
3899
|
+
const injectErrorCapturedHook = createLifeCycle('errorCaptured');
|
|
3900
|
+
function onErrorCaptured(hook, target = currentInstance) {
|
|
3901
|
+
injectErrorCapturedHook(hook, target);
|
|
3902
|
+
}
|
|
3880
3903
|
|
|
3881
3904
|
/**
|
|
3882
3905
|
* Note: also update dist/vue.runtime.mjs when adding new exports to this file.
|
|
3883
3906
|
*/
|
|
3884
|
-
const version = '2.7.
|
|
3907
|
+
const version = '2.7.10';
|
|
3885
3908
|
/**
|
|
3886
3909
|
* @internal type is manually declared in <root>/types/v3-define-component.d.ts
|
|
3887
3910
|
*/
|
|
@@ -3927,6 +3950,7 @@ var vca = /*#__PURE__*/Object.freeze({
|
|
|
3927
3950
|
getCurrentInstance: getCurrentInstance,
|
|
3928
3951
|
useSlots: useSlots,
|
|
3929
3952
|
useAttrs: useAttrs,
|
|
3953
|
+
useListeners: useListeners,
|
|
3930
3954
|
mergeDefaults: mergeDefaults,
|
|
3931
3955
|
nextTick: nextTick,
|
|
3932
3956
|
set: set,
|
|
@@ -3940,12 +3964,12 @@ var vca = /*#__PURE__*/Object.freeze({
|
|
|
3940
3964
|
onUpdated: onUpdated,
|
|
3941
3965
|
onBeforeUnmount: onBeforeUnmount,
|
|
3942
3966
|
onUnmounted: onUnmounted,
|
|
3943
|
-
onErrorCaptured: onErrorCaptured,
|
|
3944
3967
|
onActivated: onActivated,
|
|
3945
3968
|
onDeactivated: onDeactivated,
|
|
3946
3969
|
onServerPrefetch: onServerPrefetch,
|
|
3947
3970
|
onRenderTracked: onRenderTracked,
|
|
3948
|
-
onRenderTriggered: onRenderTriggered
|
|
3971
|
+
onRenderTriggered: onRenderTriggered,
|
|
3972
|
+
onErrorCaptured: onErrorCaptured
|
|
3949
3973
|
});
|
|
3950
3974
|
|
|
3951
3975
|
const seenObjects = new _Set();
|
|
@@ -3999,11 +4023,16 @@ let uid$1 = 0;
|
|
|
3999
4023
|
*/
|
|
4000
4024
|
class Watcher {
|
|
4001
4025
|
constructor(vm, expOrFn, cb, options, isRenderWatcher) {
|
|
4002
|
-
recordEffectScope(this,
|
|
4003
|
-
if (
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4026
|
+
recordEffectScope(this,
|
|
4027
|
+
// if the active effect scope is manually created (not a component scope),
|
|
4028
|
+
// prioritize it
|
|
4029
|
+
activeEffectScope && !activeEffectScope._vm
|
|
4030
|
+
? activeEffectScope
|
|
4031
|
+
: vm
|
|
4032
|
+
? vm._scope
|
|
4033
|
+
: undefined);
|
|
4034
|
+
if ((this.vm = vm) && isRenderWatcher) {
|
|
4035
|
+
vm._watcher = this;
|
|
4007
4036
|
}
|
|
4008
4037
|
// options
|
|
4009
4038
|
if (options) {
|
|
@@ -4267,7 +4296,7 @@ function initData(vm) {
|
|
|
4267
4296
|
if (!isPlainObject(data)) {
|
|
4268
4297
|
data = {};
|
|
4269
4298
|
warn$2('data functions should return an object:\n' +
|
|
4270
|
-
'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
|
|
4299
|
+
'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
|
|
4271
4300
|
}
|
|
4272
4301
|
// proxy data on instance
|
|
4273
4302
|
const keys = Object.keys(data);
|
|
@@ -4563,6 +4592,7 @@ function initMixin$1(Vue) {
|
|
|
4563
4592
|
vm.__v_skip = true;
|
|
4564
4593
|
// effect scope
|
|
4565
4594
|
vm._scope = new EffectScope(true /* detached */);
|
|
4595
|
+
vm._scope._vm = true;
|
|
4566
4596
|
// merge options
|
|
4567
4597
|
if (options && options._isComponent) {
|
|
4568
4598
|
// optimize internal component instantiation
|
|
@@ -7098,7 +7128,16 @@ function normalizeDirectives(dirs, vm) {
|
|
|
7098
7128
|
}
|
|
7099
7129
|
res[getRawDirName(dir)] = dir;
|
|
7100
7130
|
if (vm._setupState && vm._setupState.__sfc) {
|
|
7101
|
-
|
|
7131
|
+
const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
|
|
7132
|
+
if (typeof setupDef === 'function') {
|
|
7133
|
+
dir.def = {
|
|
7134
|
+
bind: setupDef,
|
|
7135
|
+
update: setupDef,
|
|
7136
|
+
};
|
|
7137
|
+
}
|
|
7138
|
+
else {
|
|
7139
|
+
dir.def = setupDef;
|
|
7140
|
+
}
|
|
7102
7141
|
}
|
|
7103
7142
|
dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
|
|
7104
7143
|
}
|
|
@@ -10836,10 +10875,7 @@ function genElement(el, state) {
|
|
|
10836
10875
|
// check if this is a component in <script setup>
|
|
10837
10876
|
const bindings = state.options.bindings;
|
|
10838
10877
|
if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
|
|
10839
|
-
tag =
|
|
10840
|
-
checkBindingType(bindings, el.tag) ||
|
|
10841
|
-
checkBindingType(bindings, camelize(el.tag)) ||
|
|
10842
|
-
checkBindingType(bindings, capitalize(camelize(el.tag)));
|
|
10878
|
+
tag = checkBindingType(bindings, el.tag);
|
|
10843
10879
|
}
|
|
10844
10880
|
if (!tag)
|
|
10845
10881
|
tag = `'${el.tag}'`;
|
|
@@ -10856,9 +10892,29 @@ function genElement(el, state) {
|
|
|
10856
10892
|
}
|
|
10857
10893
|
}
|
|
10858
10894
|
function checkBindingType(bindings, key) {
|
|
10859
|
-
const
|
|
10860
|
-
|
|
10861
|
-
|
|
10895
|
+
const camelName = camelize(key);
|
|
10896
|
+
const PascalName = capitalize(camelName);
|
|
10897
|
+
const checkType = (type) => {
|
|
10898
|
+
if (bindings[key] === type) {
|
|
10899
|
+
return key;
|
|
10900
|
+
}
|
|
10901
|
+
if (bindings[camelName] === type) {
|
|
10902
|
+
return camelName;
|
|
10903
|
+
}
|
|
10904
|
+
if (bindings[PascalName] === type) {
|
|
10905
|
+
return PascalName;
|
|
10906
|
+
}
|
|
10907
|
+
};
|
|
10908
|
+
const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
|
|
10909
|
+
checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
|
|
10910
|
+
if (fromConst) {
|
|
10911
|
+
return fromConst;
|
|
10912
|
+
}
|
|
10913
|
+
const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
|
|
10914
|
+
checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
|
|
10915
|
+
checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
|
|
10916
|
+
if (fromMaybeRef) {
|
|
10917
|
+
return fromMaybeRef;
|
|
10862
10918
|
}
|
|
10863
10919
|
}
|
|
10864
10920
|
// hoist static sub-trees out
|