vue 2.7.7 → 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.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.7.7
2
+ * Vue.js v2.7.8
3
3
  * (c) 2014-2022 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -1007,7 +1007,7 @@ function defineReactive(obj, key, val, customSetter, shallow, mock) {
1007
1007
  // #7981: for accessor properties without setter
1008
1008
  return;
1009
1009
  }
1010
- else if (isRef(value) && !isRef(newVal)) {
1010
+ else if (!shallow && isRef(value) && !isRef(newVal)) {
1011
1011
  value.value = newVal;
1012
1012
  return;
1013
1013
  }
@@ -2310,7 +2310,19 @@ function createSetupContext(vm) {
2310
2310
  var exposeCalled = false;
2311
2311
  return {
2312
2312
  get attrs() {
2313
- return initAttrsProxy(vm);
2313
+ if (!vm._attrsProxy) {
2314
+ var proxy = (vm._attrsProxy = {});
2315
+ def(proxy, '_v_attr_proxy', true);
2316
+ syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
2317
+ }
2318
+ return vm._attrsProxy;
2319
+ },
2320
+ get listeners() {
2321
+ if (!vm._listenersProxy) {
2322
+ var proxy = (vm._listenersProxy = {});
2323
+ syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
2324
+ }
2325
+ return vm._listenersProxy;
2314
2326
  },
2315
2327
  get slots() {
2316
2328
  return initSlotsProxy(vm);
@@ -2331,20 +2343,12 @@ function createSetupContext(vm) {
2331
2343
  }
2332
2344
  };
2333
2345
  }
2334
- function initAttrsProxy(vm) {
2335
- if (!vm._attrsProxy) {
2336
- var proxy = (vm._attrsProxy = {});
2337
- def(proxy, '_v_attr_proxy', true);
2338
- syncSetupAttrs(proxy, vm.$attrs, emptyObject, vm);
2339
- }
2340
- return vm._attrsProxy;
2341
- }
2342
- function syncSetupAttrs(to, from, prev, instance) {
2346
+ function syncSetupProxy(to, from, prev, instance, type) {
2343
2347
  var changed = false;
2344
2348
  for (var key in from) {
2345
2349
  if (!(key in to)) {
2346
2350
  changed = true;
2347
- defineProxyAttr(to, key, instance);
2351
+ defineProxyAttr(to, key, instance, type);
2348
2352
  }
2349
2353
  else if (from[key] !== prev[key]) {
2350
2354
  changed = true;
@@ -2358,12 +2362,12 @@ function syncSetupAttrs(to, from, prev, instance) {
2358
2362
  }
2359
2363
  return changed;
2360
2364
  }
2361
- function defineProxyAttr(proxy, key, instance) {
2365
+ function defineProxyAttr(proxy, key, instance, type) {
2362
2366
  Object.defineProperty(proxy, key, {
2363
2367
  enumerable: true,
2364
2368
  configurable: true,
2365
2369
  get: function () {
2366
- return instance.$attrs[key];
2370
+ return instance[type][key];
2367
2371
  }
2368
2372
  });
2369
2373
  }
@@ -2384,17 +2388,27 @@ function syncSetupSlots(to, from) {
2384
2388
  }
2385
2389
  }
2386
2390
  /**
2387
- * @internal use manual type def
2391
+ * @internal use manual type def because public setup context type relies on
2392
+ * legacy VNode types
2388
2393
  */
2389
2394
  function useSlots() {
2390
2395
  return getContext().slots;
2391
2396
  }
2392
2397
  /**
2393
- * @internal use manual type def
2398
+ * @internal use manual type def because public setup context type relies on
2399
+ * legacy VNode types
2394
2400
  */
2395
2401
  function useAttrs() {
2396
2402
  return getContext().attrs;
2397
2403
  }
2404
+ /**
2405
+ * Vue 2 only
2406
+ * @internal use manual type def because public setup context type relies on
2407
+ * legacy VNode types
2408
+ */
2409
+ function useListeners() {
2410
+ return getContext().listeners;
2411
+ }
2398
2412
  function getContext() {
2399
2413
  if (process.env.NODE_ENV !== 'production' && !currentInstance) {
2400
2414
  warn$2("useContext() called without active instance.");
@@ -3000,12 +3014,19 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
3000
3014
  if (vm._attrsProxy) {
3001
3015
  // force update if attrs are accessed and has changed since it may be
3002
3016
  // passed to a child component.
3003
- if (syncSetupAttrs(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm)) {
3017
+ if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
3004
3018
  needsForceUpdate = true;
3005
3019
  }
3006
3020
  }
3007
3021
  vm.$attrs = attrs;
3008
- vm.$listeners = listeners || emptyObject;
3022
+ // update listeners
3023
+ listeners = listeners || emptyObject;
3024
+ var prevListeners = vm.$options._parentListeners;
3025
+ if (vm._listenersProxy) {
3026
+ syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
3027
+ }
3028
+ vm.$listeners = vm.$options._parentListeners = listeners;
3029
+ updateComponentListeners(vm, listeners, prevListeners);
3009
3030
  // update props
3010
3031
  if (propsData && vm.$options.props) {
3011
3032
  toggleObserving(false);
@@ -3020,11 +3041,6 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
3020
3041
  // keep a copy of raw propsData
3021
3042
  vm.$options.propsData = propsData;
3022
3043
  }
3023
- // update listeners
3024
- listeners = listeners || emptyObject;
3025
- var oldListeners = vm.$options._parentListeners;
3026
- vm.$options._parentListeners = listeners;
3027
- updateComponentListeners(vm, listeners, oldListeners);
3028
3044
  // resolve slots + force update if has children
3029
3045
  if (needsForceUpdate) {
3030
3046
  vm.$slots = resolveSlots(renderChildren, parentVnode.context);
@@ -3986,7 +4002,7 @@ var onRenderTriggered = createLifeCycle('renderTriggered');
3986
4002
  /**
3987
4003
  * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
3988
4004
  */
3989
- var version = '2.7.7';
4005
+ var version = '2.7.8';
3990
4006
  /**
3991
4007
  * @internal type is manually declared in <root>/types/v3-define-component.d.ts
3992
4008
  */
@@ -10942,10 +10958,7 @@ function genElement(el, state) {
10942
10958
  // check if this is a component in <script setup>
10943
10959
  var bindings = state.options.bindings;
10944
10960
  if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
10945
- tag =
10946
- checkBindingType(bindings, el.tag) ||
10947
- checkBindingType(bindings, camelize(el.tag)) ||
10948
- checkBindingType(bindings, capitalize(camelize(el.tag)));
10961
+ tag = checkBindingType(bindings, el.tag);
10949
10962
  }
10950
10963
  if (!tag)
10951
10964
  tag = "'".concat(el.tag, "'");
@@ -10962,9 +10975,29 @@ function genElement(el, state) {
10962
10975
  }
10963
10976
  }
10964
10977
  function checkBindingType(bindings, key) {
10965
- var type = bindings[key];
10966
- if (type && type.startsWith('setup')) {
10967
- return key;
10978
+ var camelName = camelize(key);
10979
+ var PascalName = capitalize(camelName);
10980
+ var checkType = function (type) {
10981
+ if (bindings[key] === type) {
10982
+ return key;
10983
+ }
10984
+ if (bindings[camelName] === type) {
10985
+ return camelName;
10986
+ }
10987
+ if (bindings[PascalName] === type) {
10988
+ return PascalName;
10989
+ }
10990
+ };
10991
+ var fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
10992
+ checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
10993
+ if (fromConst) {
10994
+ return fromConst;
10995
+ }
10996
+ var fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
10997
+ checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
10998
+ checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
10999
+ if (fromMaybeRef) {
11000
+ return fromMaybeRef;
10968
11001
  }
10969
11002
  }
10970
11003
  // hoist static sub-trees out
@@ -11791,4 +11824,4 @@ function getOuterHTML(el) {
11791
11824
  }
11792
11825
  Vue.compile = compileToFunctions;
11793
11826
 
11794
- 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 };
11827
+ 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 };
package/dist/vue.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.7.7
2
+ * Vue.js v2.7.8
3
3
  * (c) 2014-2022 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -1007,7 +1007,7 @@
1007
1007
  // #7981: for accessor properties without setter
1008
1008
  return;
1009
1009
  }
1010
- else if (isRef(value) && !isRef(newVal)) {
1010
+ else if (!shallow && isRef(value) && !isRef(newVal)) {
1011
1011
  value.value = newVal;
1012
1012
  return;
1013
1013
  }
@@ -2283,7 +2283,19 @@
2283
2283
  var exposeCalled = false;
2284
2284
  return {
2285
2285
  get attrs() {
2286
- return initAttrsProxy(vm);
2286
+ if (!vm._attrsProxy) {
2287
+ var proxy = (vm._attrsProxy = {});
2288
+ def(proxy, '_v_attr_proxy', true);
2289
+ syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
2290
+ }
2291
+ return vm._attrsProxy;
2292
+ },
2293
+ get listeners() {
2294
+ if (!vm._listenersProxy) {
2295
+ var proxy = (vm._listenersProxy = {});
2296
+ syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
2297
+ }
2298
+ return vm._listenersProxy;
2287
2299
  },
2288
2300
  get slots() {
2289
2301
  return initSlotsProxy(vm);
@@ -2304,20 +2316,12 @@
2304
2316
  }
2305
2317
  };
2306
2318
  }
2307
- function initAttrsProxy(vm) {
2308
- if (!vm._attrsProxy) {
2309
- var proxy = (vm._attrsProxy = {});
2310
- def(proxy, '_v_attr_proxy', true);
2311
- syncSetupAttrs(proxy, vm.$attrs, emptyObject, vm);
2312
- }
2313
- return vm._attrsProxy;
2314
- }
2315
- function syncSetupAttrs(to, from, prev, instance) {
2319
+ function syncSetupProxy(to, from, prev, instance, type) {
2316
2320
  var changed = false;
2317
2321
  for (var key in from) {
2318
2322
  if (!(key in to)) {
2319
2323
  changed = true;
2320
- defineProxyAttr(to, key, instance);
2324
+ defineProxyAttr(to, key, instance, type);
2321
2325
  }
2322
2326
  else if (from[key] !== prev[key]) {
2323
2327
  changed = true;
@@ -2331,12 +2335,12 @@
2331
2335
  }
2332
2336
  return changed;
2333
2337
  }
2334
- function defineProxyAttr(proxy, key, instance) {
2338
+ function defineProxyAttr(proxy, key, instance, type) {
2335
2339
  Object.defineProperty(proxy, key, {
2336
2340
  enumerable: true,
2337
2341
  configurable: true,
2338
2342
  get: function () {
2339
- return instance.$attrs[key];
2343
+ return instance[type][key];
2340
2344
  }
2341
2345
  });
2342
2346
  }
@@ -2357,17 +2361,27 @@
2357
2361
  }
2358
2362
  }
2359
2363
  /**
2360
- * @internal use manual type def
2364
+ * @internal use manual type def because public setup context type relies on
2365
+ * legacy VNode types
2361
2366
  */
2362
2367
  function useSlots() {
2363
2368
  return getContext().slots;
2364
2369
  }
2365
2370
  /**
2366
- * @internal use manual type def
2371
+ * @internal use manual type def because public setup context type relies on
2372
+ * legacy VNode types
2367
2373
  */
2368
2374
  function useAttrs() {
2369
2375
  return getContext().attrs;
2370
2376
  }
2377
+ /**
2378
+ * Vue 2 only
2379
+ * @internal use manual type def because public setup context type relies on
2380
+ * legacy VNode types
2381
+ */
2382
+ function useListeners() {
2383
+ return getContext().listeners;
2384
+ }
2371
2385
  function getContext() {
2372
2386
  if (!currentInstance) {
2373
2387
  warn$2("useContext() called without active instance.");
@@ -2968,12 +2982,19 @@
2968
2982
  if (vm._attrsProxy) {
2969
2983
  // force update if attrs are accessed and has changed since it may be
2970
2984
  // passed to a child component.
2971
- if (syncSetupAttrs(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm)) {
2985
+ if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
2972
2986
  needsForceUpdate = true;
2973
2987
  }
2974
2988
  }
2975
2989
  vm.$attrs = attrs;
2976
- vm.$listeners = listeners || emptyObject;
2990
+ // update listeners
2991
+ listeners = listeners || emptyObject;
2992
+ var prevListeners = vm.$options._parentListeners;
2993
+ if (vm._listenersProxy) {
2994
+ syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
2995
+ }
2996
+ vm.$listeners = vm.$options._parentListeners = listeners;
2997
+ updateComponentListeners(vm, listeners, prevListeners);
2977
2998
  // update props
2978
2999
  if (propsData && vm.$options.props) {
2979
3000
  toggleObserving(false);
@@ -2988,11 +3009,6 @@
2988
3009
  // keep a copy of raw propsData
2989
3010
  vm.$options.propsData = propsData;
2990
3011
  }
2991
- // update listeners
2992
- listeners = listeners || emptyObject;
2993
- var oldListeners = vm.$options._parentListeners;
2994
- vm.$options._parentListeners = listeners;
2995
- updateComponentListeners(vm, listeners, oldListeners);
2996
3012
  // resolve slots + force update if has children
2997
3013
  if (needsForceUpdate) {
2998
3014
  vm.$slots = resolveSlots(renderChildren, parentVnode.context);
@@ -3941,7 +3957,7 @@
3941
3957
  /**
3942
3958
  * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
3943
3959
  */
3944
- var version = '2.7.7';
3960
+ var version = '2.7.8';
3945
3961
  /**
3946
3962
  * @internal type is manually declared in <root>/types/v3-define-component.d.ts
3947
3963
  */
@@ -3987,6 +4003,7 @@
3987
4003
  getCurrentInstance: getCurrentInstance,
3988
4004
  useSlots: useSlots,
3989
4005
  useAttrs: useAttrs,
4006
+ useListeners: useListeners,
3990
4007
  mergeDefaults: mergeDefaults,
3991
4008
  nextTick: nextTick,
3992
4009
  set: set,
@@ -10937,10 +10954,7 @@
10937
10954
  // check if this is a component in <script setup>
10938
10955
  var bindings = state.options.bindings;
10939
10956
  if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
10940
- tag =
10941
- checkBindingType(bindings, el.tag) ||
10942
- checkBindingType(bindings, camelize(el.tag)) ||
10943
- checkBindingType(bindings, capitalize(camelize(el.tag)));
10957
+ tag = checkBindingType(bindings, el.tag);
10944
10958
  }
10945
10959
  if (!tag)
10946
10960
  tag = "'".concat(el.tag, "'");
@@ -10957,9 +10971,29 @@
10957
10971
  }
10958
10972
  }
10959
10973
  function checkBindingType(bindings, key) {
10960
- var type = bindings[key];
10961
- if (type && type.startsWith('setup')) {
10962
- return key;
10974
+ var camelName = camelize(key);
10975
+ var PascalName = capitalize(camelName);
10976
+ var checkType = function (type) {
10977
+ if (bindings[key] === type) {
10978
+ return key;
10979
+ }
10980
+ if (bindings[camelName] === type) {
10981
+ return camelName;
10982
+ }
10983
+ if (bindings[PascalName] === type) {
10984
+ return PascalName;
10985
+ }
10986
+ };
10987
+ var fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
10988
+ checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
10989
+ if (fromConst) {
10990
+ return fromConst;
10991
+ }
10992
+ var fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
10993
+ checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
10994
+ checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
10995
+ if (fromMaybeRef) {
10996
+ return fromMaybeRef;
10963
10997
  }
10964
10998
  }
10965
10999
  // hoist static sub-trees out